Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Combining 2 regexes to 1

Reply
Thread Tools

Combining 2 regexes to 1

 
 
Niklasro(.appspot)
Guest
Posts: n/a
 
      08-30-2010
Hello, Suspecting it's completely doable combining these 2 regexes to
just 1 expression I'm looking for the working syntax. If you know then
kindly inform. Thanks in advance
('/a/([^/]*)',List), #list
('/a([^/]*)',List), #list
Niklas Rosencrantz
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      08-30-2010
On Sun, Aug 29, 2010 at 7:40 PM, Niklasro(.appspot) <(E-Mail Removed)> wrote:
> Hello, Suspecting it's completely doable combining these 2 regexes to
> just 1 expression I'm looking for the working syntax. If you know then
> kindly inform. Thanks in advance
> ('/a/([^/]*)',List), #list
> ('/a([^/]*)',List), #list


Er,

/a(/?)([^/]*)

?

Cheers,
Chris
--
Parentheses probably extraneous.
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      08-30-2010
On 30/08/2010 03:40, Niklasro(.appspot) wrote:
> Hello, Suspecting it's completely doable combining these 2 regexes to
> just 1 expression I'm looking for the working syntax. If you know then
> kindly inform. Thanks in advance
> ('/a/([^/]*)',List), #list
> ('/a([^/]*)',List), #list


('/a/?([^/]*)', List), #list
 
Reply With Quote
 
Niklasro(.appspot)
Guest
Posts: n/a
 
      08-30-2010
Many thanks. It works. You also helped me refactor these

('/([0-9]*)/?([^/]*)',AById),#id2a
('/([0-9]*)',AById)

to just 1

('/([0-9]*)/?([^/]*)',AById),#id2a

It's from the appspot framework.
Sincerely
Niklas R
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MoinMoin WikiName and python regexes Ara.T.Howard Python 6 06-26-2005 05:47 PM
Trouble with regexes Fernando Rodriguez Python 2 05-27-2005 04:08 AM
convert list of strings to set of regexes; convert list of strings to trie Klaus Neuner Python 7 07-26-2004 07:25 AM
Does Python optimize regexes? Jason Smith Python 5 07-03-2004 02:36 PM
File.separatorChar and regexes. Roedy Green Java 0 08-22-2003 02:43 AM



Advertisments