search for sting with and store in variable

Can you help me search of a string and store it in a variable?

 var strMatches = PageText.match('HQID:');

This will search the page for the word HQID and store it in "strMatches"

There are 10 random numbers after HQID that I need stored in the variable instead of HQID.  

Can you help with this?
LVL 1
ForLoop5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SStoryCommented:
I assume you mean 10 random digits after HQID:
When it finds the string does it give you a position? You will need the starting position of the string, then use .substring to get part of it.
http://wwww.w3schools.com/jsref/jsref_substring.asp

Or if PageTextmatch takes regular expressions, that would be easier. You could tell it to find
HQID: and any 10 digits.
http://www.javascriptkit.com/javatutors/redev2.shtml

I'm not real good that them, but part would be something like
[0-9]{10}

You'd have to get the literal HQID: in front of that.  So something like
^[0-9]{10}

I don't remember how to do literal text
I'm not sure if you can just do
^HQID:[0-9]{10}
0
ProculopsisCommented:
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - jsFiddle demo by Proculopsis</title>
 
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
 
 <script type='text/javascript'>//<![CDATA[
$(function(){
jQuery(document).ready(function() {

    var strMatches = $("body").text().match(/HQID:\d+/g);

    $(strMatches).each(function(index) {

        strMatches[index] = this.replace(/\D/g, "");

    });

    alert(strMatches);

});


});//]]>  

</script>


</head>
<body>
  Lorem ipsum dolor sit amet, consectetur HQID:123 adipisicing elit, sed do eiusmod tempor incididunt ut labore et HQID:321 dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor HQID:1 in reprehenderit in voluptate velit esse cillum dolore eu fugiat HQID:876 nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt HQID:666 mollit anim id est laborum.

</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ForLoop5Author Commented:
Much appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.