Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Executing CGI/web form directives in regex substitution without pages of code

by 1nickt (Canon)
on Feb 19, 2020 at 20:12 UTC ( [id://11113177]=note: print w/replies, xml ) Need Help??


in reply to Executing CGI/web form directives in regex substitution without pages of code

Hi, have you tried compiling your pattern with qr//?


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Executing CGI/web form directives in regex substitution without pages of code
by Your Mother (Archbishop) on Feb 19, 2020 at 20:35 UTC
    Hi, have you tried compiling your pattern with qr//?

    Or properly indenting? :P

      It is indented differently in my code. I was actually surprised after pasting and posting it here that it displayed as it does, and I assumed something had removed some of the tabs. In retrospect, it probably has more to do with the fact that my text editor uses a different (user-adjustable, and font-related) tab setting.

      Blessings,

      ~Polyglot~

        I was just teasing. :P Could be / probably is that the indenting is tabs. They collapse in HTML—and many editors for that matter—by default. Tabs are wonderful where they are set properly, not so great in code portability. You can do a find replace with 4 (standard) spaces before pasting it into the post to get a more readable layout.

Re^2: Executing CGI/web form directives in regex substitution without pages of code
by Polyglot (Chaplain) on Feb 19, 2020 at 21:12 UTC

    qr// does not appear to be designed to encapsulate the entire regex substitution expression, only the portion of it that would ordinarily be contained in the match section. I need something that will allow the substitution to be flagged for case-insensitive matching via the //i operator, in addition to the other portions (match / substitute) of the operation coming from user input (variable).

    For example, trying this did not work for me:

    $substitution = qr/s~$sv$ch$ww$regexM$ww$ch$ev~$regexR~g$regexI/; $line =~ $substitution;

    Blessings,

    ~Polyglot~

      I guess here you miss the possibility to have modifiers within the regular expression? A postponed /i modifier can also be written as (?i) within the regex - and in this fashion used in qr//.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found