Question: I need to extract string from html code.
I have a regexp. After I open file (or after I make "get" request) I need to find pattern. 

So, I have an html code and I want to find such string:

`<input type="hidden" name="qid" ... anything is possible bla="blabla" ... value="8">`

I want to find the string **qid**, then find after it the string **value="435345"** and extract 435345. 

Now I am just trying to find this string (I have already done it) and then I will make a replacement (I am going to do it), but this code couldn't find the pattern. What is wrong?

```
open(URLS_OUT, $foundResults);
@lines = <URLS_OUT>;
$content = join('', @lines);

$content =~ /<qid\"\s*value=[^>][0-9]+/;
print 'Yes'.$1.'\n';

close(URLS_OUT);

```

or this code:

```
my $content = $response->content(); 

while ($content =~ /<qid\"\s*value=[^>][0-9]+/g)
    {
        print 'Yes'.$1.'\n';
    }

```

I have checked that the file is not empty and it is opened correctly (I have printed it out), but I the program can't find pattern. What is wrong? I have checked the regular expression using this cite (and some others): <http://gskinner.com/RegExr/>
It shows that the regular expression is correct and finds what I need.

Answer: 
Your idea how:

```
$content =~ /<qid\"\s*value=[^>][0-9]+/;

```

works is wrong. Please study [basic Regex usage in Perl](http://perldoc.perl.org/perlre.html).

BTW: you shouldn't parse HTML by regex. There are a lot [examples on the web and on SO](https://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not) how to do that correctly. Look it up!

---

For learning purpose, your regex would look like this (according to your comment):

```
my $content = q{
 <input type="hidden" id="qid" name="qid" bla="blabla" value="8">
 <input type="hidden" id="qid" name="qid" bla="blabla" value="98">
 <input type="hidden" id="qid" name="qid" bla="blabla" value="788">
 <input type="hidden" id="qid" name="qid" bla="blabla" value="128">
 <input type="hidden" id="qid" name="qid" bla="blabla" value="8123">
};
my $regex = qr{ name=     # find the attribute 'name'
                "qid"     # with a content of "quid"
                .+?       # now search along until the next 'value'
                value=    # the following attribute 'value' 
                "(\d+)    # find the number and capture it
              }x;   ## allow the regex to be formatted   

while( $content =~ /$regex/g ) { # /g - search along
   print "Yes $1 \n"
}  

```

---

After you got this working, please study how to read the content with an [HTML-Parser](http://search.cpan.org/dist/HTML-Parser/Parser.pm).
For the sample you give, your regular expression should look something like this:

```
$content =~ m{
               \"       # match a double quote
               qid      # match the string: qid
               \"       # match a double quote
               [^>]*    # match anything but the closing >
               value    # match the string: value
               \=       # match an equal sign
               \"       # match a double quote
               (\d+)    # capture a string of digits
               \"       # match a double quote
             }msx;

```