Page 1 of 1

finding <

Posted: Wed Jan 07, 2009 1:15 pm
by michelvh
I have to find "five < six"
in the next line:

five < six<Tr>

Can someone give a regexp for this?

Can't find the solution.

Michel

Re: finding <

Posted: Wed Jan 07, 2009 2:05 pm
by prometheuzz
michelvh wrote:I have to find "five < six"
in the next line:

five < six<Tr>

Can someone give a regexp for this?

Can't find the solution.

Michel
The regex for that is:

Code: Select all

'/five < six/'
If that was not the answer you were hoping for, I suggest you provide some additional information. Because beside that single example, you did not explain anything about your input.

Good luck.

Re: finding <

Posted: Wed Jan 07, 2009 2:12 pm
by michelvh
That's not what I am looking for, "five < six"
is just an example.

What I have to find is
from the beginning of the string all
characters until a < is followed by a T. (not a space)

Michel

Re: finding <

Posted: Wed Jan 07, 2009 2:22 pm
by andyhoneycutt

Code: Select all

'/(.+)<T/'
-Andy

Re: finding <

Posted: Wed Jan 07, 2009 2:30 pm
by prometheuzz
michelvh wrote:That's not what I am looking for, "five < six"
is just an example.
...
Yes, I figured that much. My point was that you gave a very unclear explanation of your problem with just a single example and without a proper explanation of your requirement. Wouldn't you agree?

Re: finding <

Posted: Wed Jan 07, 2009 2:31 pm
by prometheuzz
andyhoneycutt wrote:

Code: Select all

'/(.+)<T/'
-Andy
That won't work for:

Code: Select all

five < six<Tr seven > six <Tr>
and

Code: Select all

five < six \n seven > six <Tr

Re: finding <

Posted: Mon Jan 12, 2009 12:41 pm
by andyhoneycutt
True, it won't work for the above examples. It almost matches for the criteria specified, with the exception that I didn't match for white space. This may be a more precise pattern:

Code: Select all

'/([\w\s]+<[\w\s]+)+<T/'
This matches:

Code: Select all

'a < b <T'
"a \n<b <\n c...<T"
'a < b < c ... <T'
-Andy

Re: finding <

Posted: Tue Jan 20, 2009 9:18 am
by GeertDD
What I have to find is
from the beginning of the string all
characters until a < is followed by a T. (not a space)

Code: Select all

^.*?(?=<T)