|
List Info
Thread: negating entire grouping
|
|
| negating entire grouping |

|
2006-03-18 22:43:37 |
"gj" <gjcasimir gmail.com> wrote:
>
>Hi i am wondering if it is possible to negate a grouping
example
>(match) like you do with character classes [^match]
>
>I was thinking of doing it using backreferences but i
found out they
>are not supported with character classes
(match)([^\1])+
You can negate a match -- for example
match(?!this)
Would match "match" "matchsticks"
"matches" but would not match
"matchthis".
Example: http://tinyurl.com/s5zen
That's only going to negate the text immediately following
the match,
though. What it sounds like you'll need to do is use a few
preg_matches to
get what you want -- match each table cell, and then run a
second
preg_match on the contents of that match to check and see if
your header is
there. If it is, add it to the array; if not, move on.
A.
--
Remember, no matter where you go, there you are. -Buckaroo
Banzai
Online Regex find/replace utility: http://rereplace.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-19 07:37:16 |
In other words i can sa (match)(?!\1)+(match)
Match a chunk of text the scan through until you obtain that
same chunk
of text again.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-20 01:45:53 |
> Match a chunk of text the scan through until you obtain
that same chunk
> of text again.
Easy:
(match).*?\1
turn on "dot matches newlines" (often called
"single line mode")
Depending on the regex engine and the size of the data
you're working
with, simply finding "match" and then using the
match result in a
literal string search may be faster.
Kind regards,
Jan Goyvaerts
--
http://www.regexbuddy.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-20 13:36:39 |
|
Looking at your solution...in theory if you have for example
match dot star match dot star match dot star match
won't your example match all occurances of match in between up until the last one??
what i am trying to do is a preg_match_all that will return an array with eatch match plus the contents directly following it until the next match. so the above would be.
[0] ->match dot star
[1] ->match dot star
[2] ->match dot star
[3] ->match
On 3/19/06, Jan Goyvaerts <jgsoft.com">jg jgsoft.com> wrote:
> Match a chunk of text the scan through until you obtain that same chunk > of text again.
Easy:
(match).*?\1
turn on "dot matches newlines" (often called "single line mode")
Depending on the regex engine and the size of the data you're working with, simply finding "match" and then using the match result in a
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Regex" group. To post to this group, send email to regex googlegroups.com To unsubscribe from this group, send email to regex-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/regex -~----------~----~----~----~------~----~------~--~---
|
| negating entire grouping |

|
2006-03-20 16:10:38 |
Garvin J Casimir wrote:
> Looking at your solution...in theory if you have for
example
>
> match *dot star* match *dot star* match *dot star*
match
>
> won't your example match all occurances of match in
between up until the
> last one??
>
Garvin, u r apparently missing the point in Jan's reex:
(match).*?\1
he's using a LAZY match here , not greedy one:
.*?
so .*? will match everything until the next occurrence of
'match', NOT
the last one.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-20 16:16:36 |
|
ohhhh thank you so much. Please forgive me i am very new to regexp. I just started reading the book 'Mastering Regular Expressions" from o'reilly.
I think i understand now. Thank you for your patience. I will definately try it out.
On 3/20/06, Sergei Z <hotmail.com">s_zarembo hotmail.com> wrote:
Garvin J Casimir wrote: > Looking at your solution...in theory if you have for example >
> match *dot star* match *dot star* match *dot star* match > > won't your example match all occurances of match in between up until the > last one?? >
Garvin, u r apparently missing the point in Jan's reex:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Regex" group. To post to this group, send email to regex googlegroups.com To unsubscribe from this group, send email to regex-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/regex -~----------~----~----~----~------~----~------~--~---
|
| negating entire grouping |

|
2006-03-21 11:18:54 |
> what i am trying to do is a preg_match_all that will
return an array with
> eatch match plus the contents directly following it
until the next match. so
> the above would be.
That sounds like job for the preg_split function.
A key part of a programmer's skill regarding regular
expressions is to
know when to use a regular expression, and when to use
additional logic
in PHP/whatever.
match.*?match.*?match.*?match.*?match.*?match is going to be
very slow
if your subject string is very long, and contains only 5
occurrences of
"match" (i.e. one too few). This is the same
situation I explain in
the HTML example at http:
//www.regular-expressions.info/atomic.html
Kind regards,
Jan Goyvaerts
--
http://www.regexbuddy.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-21 11:48:52 |
|
This is a GREAT! discussion i am getting to learn alot.
I am trying to match html tables with nested tables.
1) The container tables have their attributes in a certain order so the regex i use to match the container table /<table\s?width=\"100%\"(.*)>/
2) i learned to construct my regex in parts so the second part is to get the end of the table. Each container table is directly followed by a <br> tag so i can safely say. I use [\s] to account for any tabs and line breaks that may fall between the end of the table and the <br> tag.
/<\/table>[\s]+<br>/
3) And finally i want match 1 + match 2 + anything in between them.
It seems the preg split might just do the trick. Guys feel free to pick at my thinking...i am here to learn. Thanx
|
| negating entire grouping |

|
2006-03-21 15:51:04 |
we recently discussed matching nested tags here:
http://groups.google.com/group/regex/brow
se_frm/thread/69f90a867d5e7812
it might be of interest to u
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|
|
| negating entire grouping |

|
2006-03-21 17:26:52 |
|
actually the nested tables are not important. I just want the containing tables and all their contents....i only mentioned nested tables because because then its not as easy as matching </table> the end table tag. I will review the thread. Thank you.
|
|
|