POSIX seems not to be working...

General questions about using TextPad

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

Post Reply
SergeantRock
Posts: 5
Joined: Fri May 05, 2006 2:21 pm

POSIX seems not to be working...

Post by SergeantRock »

Hi.

POSIX seems to be acting up in TxtP. Alternatively, I could be making a mistake with my syntax... :)

Here's my XHTML:

Code: Select all

<li><a href="">shell_IE5.css</a></li>
I want to grab the first part of the filename inside the tags (before the extension) and repeat it in the href, like so:

Code: Select all

<li><a href="shell_IE5">shell_IE5.css</a></li>
My RegExp is:

Code: Select all

Find: ""\(>[^\.]+\)

Code: Select all

Replace: "\1"\1
I'm getting a 'Cannot find Regular Expression:'

Any ideas?
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That's non-Posix syntax (and your handling of the > isn't quite right). You need
Find what: "">([^.]+)
Replace with: "\1">\1

[X] Regular expression
(You don't need to quote the dot in the character class, which is itself a quoting operator.)
SergeantRock
Posts: 5
Joined: Fri May 05, 2006 2:21 pm

Post by SergeantRock »

Thank you very much! Now I'm confused as to what's POSIX and what ain't...
But cheers for the help!
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for:

Code: Select all

(.*=")(">)(.*)\.
Replace with:

Code: Select all

\1\3\2\3\.
This:

Code: Select all

<li><a href="">shell_IE5.css</a></li>
Becomes this:

Code: Select all

<li><a href="shell_IE5">shell_IE5.css</a></li>
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Bob Hansen wrote:Search for:

Code: Select all

(.*=")(">)(.*)\.
But beware of the longest-match rule. Consider what happens if there are two matching <a> elements on one line, or, indeed, just one of them, with a dot somewhere to the right of it...

Code: Select all

(=")(">)([^.<]*)\.
is safer.
Post Reply