quickie rex expression

Post Reply
jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

quickie rex expression

Post by jkj2001 »

Hi,

I'm trying find all occurences of this in one of my fields--

3(a)(3)

Only thing is, the spelling might also be:

3[a][3]

Or other, non-alpha characters between the threes and the "a". I'd like to cull together a search to handle those possibilities, but don't know the proper REX terminology. Can't use \alpha, for example, since parens or brackets or curly brackets don't fall under it's purview.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

quickie rex expression

Post by mark »

Make a set containing [( and a set containing )].
3[\[(]a[\])][\[(]3[\])]
jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

quickie rex expression

Post by jkj2001 »

Thanks-- that helped a lot.

Can I ask another, related question? Regarding when to escape REX characters.

Say I have some text like this:

a-2-p-2

I want to search it using tsql, so myself, I'd do something like this:

tsql "select * from mytable where myfield like 'a-2-p-2'";

However, I'm not sure if I have to escape those minus signs with backslashes? I didn't invoke REX above, since I didn't use a forward slash at the beginning of my term, so I'm not sure if I have to escape anything.

What if I want to match exact text in my field, should I enclose the term above in double-quotes, eg:

tsql "select * from mytable where myfield like '\"a-2-p-2\"'";

Or is that not enough and I have to do something else? Thanks again.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

quickie rex expression

Post by mark »

You only have to escape things when they would be considered "special". Using quotes is not the same as escaping with \. Quotes just bind phrases.

myfield like 'a-2-p-2'
will look for the phrase "a-2-p-2" hyphens and spaces will be treated identically in regular terms unless you turn off hyphenphrase. In rex hyphen and space are distinct.
jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

quickie rex expression

Post by jkj2001 »

Hmm. Well, I tried that, and got hits back which with "a-2/p-2". No doubt because hyphenphrase was on. Is it possible to turn it off when I run a tsql command, or is that only a possibility with a vortex script?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

quickie rex expression

Post by mark »

jkj2001
Posts: 142
Joined: Fri Mar 29, 2002 1:39 pm

quickie rex expression

Post by jkj2001 »

Thanks again.

One more question, I promise!

I'm having a little trouble with using {0,1}. If I run a search like so:


select TITLE from mytable
where TITLE like '/a[\.\-_\space]{0,1}2'

I get hits back which don't make sense-- almost anything will come back, and nothing with a "2" in the field. If I put something else in the curly brackets, get rid of the zero, maybe just use a {1}, things work fine. Did I do something wrong? Obviously yes.

I'd hoped for values like "a-2" "a.2" "a 2", that kind of thing.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

quickie rex expression

Post by mark »

You forgot the = after the a.
Post Reply