List Info

Thread: Setting up looks (behind/ahead); can they be nested?




Setting up looks (behind/ahead); can they be nested?
user name
2006-06-15 18:50:00
Can one nest look aheads and behinds?

Say for example one is working CSV data that is seperated by
a comma.
With that info, one can create a look behind to start off
the regex and
a look ahead to specify the boundaries that the data can be
found in,
such as:

(?<=,|^) ... (?=,|$)

The ... above represents a general expression to consume the
textual
data and is not provided in this example.

Then one discovers that the data is quoated, such as

"1217AUXR","TEXTFORYOU","76.00
0","354,287","0.06037"

this is done for the express purpose of allowing for a comma
to be
present in the data feed. (Why they didn't use a different
delimiter is
beyond you...but now you have to consume it.)

This now harkens to the title of the subject, Since one has
defined the
first boundary by the look behind/ahead, why can't a nested
look
behind/ahead be done for the qoutes...such as

(?<=,|^) (?<=") ... (?=")(?=,|$)


Is this realistic?

advTHANKSance


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Setting up looks (behind/ahead); can they be nested?
user name
2006-06-15 20:17:17
OmegaMan wrote:
> Can one nest look aheads and behinds?
>
> Say for example one is working CSV data that is
seperated by a comma.
> With that info, one can create a look behind to start
off the regex and
> a look ahead to specify the boundaries that the data
can be found in,
> such as:
>
> (?<=,|^) ... (?=,|$)
>
> The ... above represents a general expression to
consume the textual
> data and is not provided in this example.
>
> Then one discovers that the data is quoated, such as
>
>
"1217AUXR","TEXTFORYOU","76.00
0","354,287","0.06037"
>
> this is done for the express purpose of allowing for a
comma to be
> present in the data feed. (Why they didn't use a
different delimiter is
> beyond you...but now you have to consume it.)
>
> This now harkens to the title of the subject, Since one
has defined the
> first boundary by the look behind/ahead, why can't a
nested look
> behind/ahead be done for the qoutes...such as
>
> (?<=,|^)(?<=") ... (?=")(?=,|$)

this looks a logical "AND" instead of
"nested".?? 

>
> Is this realistic?

you can write it that way, but it will never succeed, say,
at the first
place (?<=,|^)(?<="), you need to guarentee that
the preceding is
either a comma or beginning of line, and meanwhile a
double-quote, it's
logically not possible, isn't it?   

Xicheng


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Setting up looks (behind/ahead); can they be nested?
user name
2006-06-15 20:41:37
Hi Xicheng,

Right, I understand...it now goes into that space between
the universes
when looking for the first quote which can never be before
the
beginning of the line.... lol  That is subtle....

Thanks for enlightening me on that.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Setting up looks (behind/ahead); can they be nested?
user name
2006-06-15 22:14:20
OmegaMan wrote:
> Hi Xicheng,
>
> Right, I understand...it now goes into that space
between the universes
> when looking for the first quote which can never be
before the
> beginning of the line.... lol  That is subtle....
>
> Thanks for enlightening me on that.

you are welcome

Actually, you can put them into one lookaround construct,
like:

   (?<=^"|,") ... (?=",|"$)

or

   (?<=(?:^|,)") ... (?="(?:,|$))

(not work in perl and python which dont support
variable-length
lookbehind.)

but why not just use double-quotes as the field
boundaries?.. 

Xicheng


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )