Current location: Hot Scripts Forums » General Web Coding » JavaScript » [SOLVED] Search () & regex exact number.


[SOLVED] Search () & regex exact number.

Reply
  #1 (permalink)  
Old 03-03-08, 09:35 AM
Snowball Snowball is offline
Newbie Coder
 
Join Date: Feb 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Search () & regex exact number.

I am using the search() function to search within a comma delimited string using join(). I need to search for an exact number such as 4 but not 14. I'm using
Code:
',?' + num[i].value + ',?'
as the regex, but that returns the extra numbers. How can I use regex to search for an exact number as retrieved by a dynamic variable (in this case 4)?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-03-08, 11:03 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Code:
'/(^|,)' + num[i].value + '($|,)/'
Like this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-03-08, 11:06 AM
Snowball Snowball is offline
Newbie Coder
 
Join Date: Feb 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, that works perfectly. Thank you very much.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Guaranteed number 1 ranking on a very popular search engine and It's free, no cost. grgx General Advertisements 0 02-16-05 08:21 AM
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 01:38 PM
Simple search script niceguyonline Script Requests 3 03-08-04 12:09 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 08:19 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.