Page 1 of 1
quickie rex expression
Posted: Tue Jan 27, 2004 7:23 pm
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.
quickie rex expression
Posted: Tue Jan 27, 2004 7:48 pm
by mark
Make a set containing [( and a set containing )].
3[\[(]a[\])][\[(]3[\])]
quickie rex expression
Posted: Wed Jan 28, 2004 12:20 pm
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.
quickie rex expression
Posted: Wed Jan 28, 2004 12:57 pm
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.
quickie rex expression
Posted: Wed Jan 28, 2004 1:39 pm
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?
quickie rex expression
Posted: Wed Jan 28, 2004 2:53 pm
by mark
http://thunderstone.master.com/texis/ma ... ch%3A&s=SS
You can set in vortex with apicp or in sql with sql set.
quickie rex expression
Posted: Wed Jan 28, 2004 5:56 pm
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.
quickie rex expression
Posted: Wed Jan 28, 2004 8:24 pm
by mark
You forgot the = after the a.