Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

select with regexp

 
   Database Help (Home) -> mySQL RSS
Next:  Oracle 10G RELEASE 1 ON HP UNIX  
Author Message
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 1) Posted: Fri Feb 18, 2005 4:40 am
Post subject: select with regexp
Archived from groups: mailing>database>mysql (more info?)

i have a column "path" with values eg.

+---------------+
| path |
+---------------+
|/path/path/path|
+---------------+
|/path/path |
+---------------+
|/path |
+---------------+

i want to select the row where there are X number of "/". I THINK i am
suppose to use regexp. anybody knows the syntax?

select path from tablename WHERE path REGEXP _____________

 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 2) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > i have a column "path" with values eg.
 >
 > +---------------+
 > | path |
 > +---------------+
 > |/path/path/path|
 > +---------------+
 > |/path/path |
 > +---------------+
 > |/path |
 > +---------------+
 >
 > i want to select the row where there are X number of "/". I THINK i am
 > suppose to use regexp. anybody knows the syntax?
 >
 > select path from tablename WHERE path REGEXP _____________

nmind. i got it.

'^(/[\\d\\w]){X}' where X is a variable<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 3) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:

 > select path from tablename WHERE path REGEXP _____________

nmind. i got it.

'^(/[\\d\\w]*?){1}'<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 4) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > - wrote:
 >
  >> select path from tablename WHERE path REGEXP _____________
 >
 >
 > nmind. i got it.
 >
 > '^(/[\\d\\w]*?){1}'

oops. doesn't work as expected.

this is the correct one i suppose.
'^(/[\\d\\w]*?){X}$' where X is the expected no. of '/'.

but how do i put a variable in there? is it
'^(/[\\d\\w]*?){' && variable && '}$'<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: select with regexp 
Back to top
Login to vote
Bill Karwin1

External


Since: Jun 17, 2004
Posts: 42



(Msg. 5) Posted: Fri Feb 18, 2005 2:33 pm
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > but how do i put a variable in there? is it
 > '^(/[\\d\\w]*?){' && variable && '}$'

This should work:

WHERE path REGEXP CONCAT('^(/[\\d\\w]*?){', variable, '}$')

Regards,
Bill K.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: select with regexp 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]