OZONE Asylum
Forums
CSS - DOM - XHTML - XML - XSL - XSLT
JavaScript Regex Issue
This page's ID:
29317
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
First, the code:[code]/* Ok, I'm using prototypejs, so $(el) is a reference to a textarea, and $F(el) is the value of that textarea */ var old_vin = get_text(vn.getElementsByTagName('old').item(0)); var new_vin = get_text(vn.getElementsByTagName('new').item(0)); $(el).value = $F(el).replace(old_vin, new_vin); var vin_only = new RegExp("^[\s]*"+new_vin+"[\s]*$", 'm'); console.log(vin_only); console.log('Only VIN('+new_vin+') on line: ', $F(el).match(vin_only)); $(el).value = $F(el).replace(vin_only, 'test');[/code] My problem is that whatever new_vin is, the regex will match it on a line by itself, but NOT if there is a space before or after it. shouldn't the [\s]* allow the spaces? [small](Edited by [url=http://www.ozoneasylum.com/user/6549]aaroncampbell[/url] on 06-29-2007 02:24)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »