Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
Reguler expression to find #number
kavin clain
Ranch Hand
Posts: 68
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am new to regular expression.
I am trying to find all occurrences of '#(number)' as in the given
string
#45, #34 and #6.
After several try did not get the correct one. Any buddy help me to write correct regular expression.
<script> ... var regExp = /[#]{1}\d{1,4}/; var str = "First number #45 and the second number #34 now the last number #6"; function doSome(){ var matches = str.match(regExp); for(var i=0;i<matches.length;i++){ alert(matches[i]); } } </script>
Chris Baron
Ranch Hand
Posts: 1061
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
you just have to add an "g" to the expression to find all occurrences.
var regExp = /[#]{1}\d{1,4}/g;
kavin clain
Ranch Hand
Posts: 68
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you, Chris. Now it is giving the desired results... thank you very much.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
string search in JS
Numeric Regular Expression
capturing keypresses and checking if alphanumeric
Counting exact matches of substring.
How to escape regular expression's special characters using javascript?
More...