in reply to Re: Using regex with a variable
in thread Using regex with a variable

First of all, sorry for the messy formatting. I am new here. Thanks to you both, using "qr" worked.

But thing is, I used these variables to reduce the time taken to match. Initially it used to take abt 30 minutes. After using variables, it takes only 10-15 sec. Now after using "qr", it again is taking longer time to match. Reducing the time is my main motto here. This variable problem came up when trying to reduce time.

Any suggestions ??

Replies are listed 'Best First'.
Re^3: Using regex with a variable
by Discipulus (Canon) on Mar 14, 2016 at 09:19 UTC
    ++ for reformatting your code..

    Now i see that $ur is declared after the regexes.. what your code is supposed to do? if you just put qr in the meanwhile $ur is uundefined and probably is not ywhat you want.. are you using strict and warnings? probably we need more informations about your intention and your possible data inputs.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Sorry for the misunderstanding. I wasn't assigning $ur with a value in code. The question is updated now. The value of $ur remains constant throughout the looping of lines. I cannot exactly paste all the code here. I am not allowed to. And yes, I am using "use Strict", "use Warnings".
        You can always change your sensible data to something else and the regex accordingly and post your intentions and some simple input.

        Whitout this it is impossible to guess what you are triyng to achieve.

        Probably a single regex can do the job you need. Here around are very good regexer (not me).

        Do not modify your original post without putting some note on changes: replies can have no sense after the modification of the original post.

        L*

        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Sorry for the misunderstanding. Im not assigning $ur with a value in code. It remains constant through out the looping process. And, I cannot exactly paste my code in here, as Im not allowed to. And yes, Im using "use strict" and "use warnings".

        Reduce the problematic code to a short stand alone example that shows the problem. See I know what I mean. Why don't you? for tricks to include sample data. If you need a lot of data, get the test script to generate it.

        We don't need to see your sensitive code or data, but we can't help much with hand wavy descriptions of the problem. We need a good representation of the structure of the code to be able to give good advice.

        Premature optimization is the root of all job security