Regexp for adding a space

General questions about using WildEdit

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
dusan
Posts: 2
Joined: Tue Feb 08, 2005 6:20 pm

Regexp for adding a space

Post by dusan »

Hi all,

I need to add a space in front of a colon : in hundreds of HTMLs, but I don't want to corrupt the links and tags that include a colon, therefore I created a list of keywords in front which the space can't be inserted.
size
family
language
align
http
ftp ....

I was thinking of an RegExp :

Search for: NOT(size|family|language|align|http|ftp):
Replace: \1 :

But I don't know how to insert "NOT" in the list of keywords :(
thank you
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Re: Regexp for adding a space

Post by ben_josephs »

You can't! Unfortunately, you can't search for text that doesn't match an arbitrary regular expression immediately preceding text that does match some other regular expression. The Boost regex library, which is what WildEdit uses, doesn't implement "look-behind assertions". (They are essentially difficult; even Perl's implementation is limited.)

But you can change the colons you want unchanged into something else that doesn't occur elsewhere in the text:
Change
(size|family|language|align|http|ftp):
to
$1¤
Then insert a space in front of each colon that remains:
Change
:
to
_:
(Use a space where I've put an underscore.)

Then recover the other colons:
Change
¤
to
:
dusan
Posts: 2
Joined: Tue Feb 08, 2005 6:20 pm

Post by dusan »

Thank you ben_josephs for this tip. I didn't think about replacing it by something else :)
I think that sovled my problem.
Post Reply