Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Eugh, regex :(

by haoess (Curate)
on Mar 25, 2009 at 09:40 UTC ( [id://753070]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Eugh, regex :(
in thread Eugh, regex :(

% cat 753064 $post_message =~ s%\Q[URL=\E([\?\%\:\/a-zA-Z0-9_\-\.]+)\Q][img]\E([\?\ +%\:\/a-zA-Z0-9_\-\.]+)\Q[/img][/URL]\E%gix; % perl -Mdiagnostics 753064 Substitution replacement not terminated at 753064 line 1 (#1) (F) The lexer couldn't find the final delimiter of an s/// or s{}{ +} construct. Remember that bracketing delimiters count nesting leve +l. Missing the leading $ from variable $s may cause this error. Uncaught exception from user code: Substitution replacement not terminated at 753064 line 1. at 753064 line 1

The error message says it all, if you want to substitute, you should tell perl, whats your substitution is.

-- Frank

Replies are listed 'Best First'.
Re^4: Eugh, regex :(
by ultranerds (Hermit) on Mar 25, 2009 at 09:46 UTC
    Oops, just saw that! Changed it, still getting errors :(

    It seems to be from this line still, cos if I comment it out - the rest of the script works fine:

    $post_message =~ s|\Q[img]\E([\?\%\:\/a-zA-Z0-9_\-\.]+)\Q[/img]\E|[img]$1[/img]|sig;
    (the above is just a more basic version of what I'm trying, to see if I can try and track down whats going on)

    Driving me nuts :(

    Cheers

    Andy

      Ah, looks like you've stumbled into a perl parsing trap:

      s||$1[/|

      This code tries to interpolate the @1 array, the index starts with a slash, parsed as the begin of a matching pattern, but missing the closing slash, that's why you get the Search pattern not terminated error. Escaping the [ with a backslash should make all things fine.

      -- Frank

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://753070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-24 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found