Hi!
If I have this:
<FONT COLOR="#cccccc">alot of text</FONT> alot of text <FONT COLOR="#cccccc">more text</FONT>
And this pattern:
<FONT COLOR="#cccccc">(.*?)<\/FONT>
And replace it with:
[hub]\1[/hub]
Then it would end up like this:
[hub]alot of text</FONT> alot of text <FONT COLOR="#cccccc">more text[/hub]
I want it to be:
[hub]alot of text[/hub] alot of text [hub]more text[/hub]
Is it possible?
Im running textPad version 4.5.0
Help!
///Brimba
Non greedy regular expression
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Jens Hollmann
Re: Non greedy regular expression
If there are no other HTML-tags between "<FONT...>" and </FONT> you could search for:
<FONT COLOR="#cccccc">\([^<]*\)</FONT>
and replace with "[hub]\1[/hub]".
"[^<]*" matches anything except a "<" which makes the regexp in a way non-greedy. But there mustn't be any other tags ("<" to be precise) between the FONT tags.
The other possibility is to record a macro. Search for the start tag "<FONT COLOR="#cccccc">" then search for the end tag "</FONT>" expanding the selection and then do your replace in the current selection.
HTH
Jens
<FONT COLOR="#cccccc">\([^<]*\)</FONT>
and replace with "[hub]\1[/hub]".
"[^<]*" matches anything except a "<" which makes the regexp in a way non-greedy. But there mustn't be any other tags ("<" to be precise) between the FONT tags.
The other possibility is to record a macro. Search for the start tag "<FONT COLOR="#cccccc">" then search for the end tag "</FONT>" expanding the selection and then do your replace in the current selection.
HTH
Jens