Regex against a scalar

From: Perl (Perl_at_nyclimits.org)
Date: 03/24/05


Date: Wed, 23 Mar 2005 17:41:31 -0800
To: "Beginner Perl" <beginners@perl.org>

Hi.

I would like to search a scalar variable and have the output to another
scalar. For example:

$test = "This is some test data";

I want another scalar, $regex to hold the output of a regular expression
lookup against $test.

So something like this:

$regex =~ /test/ running against $test. Is this possible somehow?



Relevant Pages

  • Re: how to construct regex to count no. of alphabets in a scalar variable
    ... I need some explanation on the above on how the above regex count the number of 'a' in a string. ... How do I construct a regex to count the number of 'a' within a scalar variable such as the undermentioned. ... One method I can think of is to split the scalar string into a list and then do the counting but I just feel that this in not necessary. ... first if you are counting single characters and the second otherwise: ...
    (perl.beginners)
  • Re: inefficient regex - please help!
    ... >> How could I rewrite this regex more efficiently? ... Sorry but I meant specifically "how can I write the regex" part more ... against the scalar. ...
    (comp.lang.perl.misc)
  • RE: Regex against a scalar
    ... I'm lost with this question, ... Marcos ... I would like to search a scalar variable and have the output to another ... $regex to hold the output of a regular expression ...
    (perl.beginners)
  • Re: Regex against a scalar
    ... > I would like to search a scalar variable and have the output to another ... $regex to hold the output of a regular expression ... See perlop for details and perlretut for more detailed examples. ... Offer Kaye ...
    (perl.beginners)
  • Re: regex problem
    ... I'm searching for the regular expression ... but that you're trying to use a pattern match to find a ... 1) Read the entire file into one big scalar, ...
    (comp.lang.perl.misc)