List Info

Thread: 'or' syntax in regexp...




'or' syntax in regexp...
user name
2007-12-24 06:18:15
Hi there,
Can someone please explain to me how to phrase an 'or'
conditional in
regexp? Using php, I need to rephrase this function to
search for ?
v=(any chars) followed by either a ] square bracket or an
&
ampersand.

preg_match_all("!?v=(.*?)]!",$result,$output);

Thanks a lot,
Ciaran
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: 'or' syntax in regexp...
user name
2007-12-25 19:57:38
Ciaran,

A character class can be used to specify a set of characters
that can
be matched.  The following will match ']' or '&':

[]&]

The ']' needs to be escaped, as it is a metacharacter part
of the
character class syntax.  The '|' alternation character can
be used if
the options have more than one character.  The following is
the way to
match ']' or '&' with alternation:

(]|&)

I hope this helps.

Jeff



On Dec 24, 7:18 pm, Ciaran <cronok...hotmail.com> wrote:
> Hi there,
> Can someone please explain to me how to phrase an 'or'
conditional in
> regexp? Using php, I need to rephrase this function to
search for ?
> v=(any chars) followed by either a ] square bracket or
an &
> ampersand.
>
>
preg_match_all("!?v=(.*?)]!",$result,$output);
>
> Thanks a lot,
> Ciaran
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: 'or' syntax in regexp...
user name
2007-12-26 20:51:33
Great, thanks a million Jeff! It makes a lot of sense now
that I see
it.
Ciaran
--~--~---------~--~----~------------~-------~--~----~
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-3]

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