Conditional Space

A swapping-ground for Regular Expression syntax

Conditional Space

Postby wierd0n3 » Wed Mar 04, 2009 2:23 am

I just started using this program and am currently stuck on a small issue.

here's my regex:

(\[.*\])(.*)
\2

for turning
[tag]filename.txt
to
filename.txt

this works fine if there is no space in the name, but if i have a space, it takes the whole filename out leaving just the extension

from
[tag] filename.txt
to
.txt

how would i Modify this expression to this to take into account that there MAY be a space?

Thanks in advance
wierd0n3
 
Posts: 4
Joined: Wed Mar 04, 2009 2:13 am

Re: Conditional Space

Postby wierd0n3 » Sun Mar 08, 2009 9:44 pm

ok, I figured out to set "trim" and that seems to do the trick.

Using this Formula
(\[.*\])(.*)(\s\d\d)(.*)
\2\3
(\2\3 \1 if i need to know the group)
wierd0n3
 
Posts: 4
Joined: Wed Mar 04, 2009 2:13 am


Return to Regular Expressions


cron