Regexp: modify $1 within the replace clause?

From: Yaroslav (carpathian81_at_yahoo.com)
Date: 04/16/04

  • Next message: Joe Smith: "Re: Regexp: modify $1 within the replace clause?"
    Date: 16 Apr 2004 07:41:26 -0700
    
    

    Hi all,

    Consider the following trivial example:

    $_ =~ s/<matching_expression>/<clause_that_uses_$1>/g;

    Is there a way to build such a regular expression, that matches some
    string and modifies the match (e.g. $1) before using it in the replace
    clause? What if I want to do something with $1 before I use it to
    replace something? Is there a way to insert, say, a function of $1
    there, rather than $1 itself?

    TIA.

    ~yaroslav


  • Next message: Joe Smith: "Re: Regexp: modify $1 within the replace clause?"

    Relevant Pages

    • Re: Get regular expression
      ... own tree structure. ... Expression compares a string character-by character, ... regular expression solution, which was about as close as one could get to ... the structure of the hierarchy can be inferred by using ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Get regular expression
      ... regular expression solution, which was about as close as one could get to ... first string. ... explode "ABLATION" and see subnodes of "ENDOMETRIAL ... "Heart 27.33/2" ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Regular expression optimization
      ... position in the replacement array of strings, ... > input string and a MatchEvaluator delegate. ... > The first part required combining the separate Regular Expression strings ...
      (microsoft.public.dotnet.general)
    • Small regular expression parser
      ... the goal was to develop a very simple regular expression parser. ... sets are selected using the % character instead of \. ... into the string of the start of the match and the length of the match. ... Last there are a couple macros to help with captures. ...
      (comp.lang.lisp)
    • Re: Which RegEx Testing Tool Do You Prefer?
      ... * Regular Expression Tester ... > match has been returned prior to the end of the string. ... >> a white space although in a manner that is confusing as I will point out ... >> would ignore those previous white space characters and then report 2:? ...
      (microsoft.public.dotnet.framework.aspnet)