|
From: Martin Honnen on 24 Apr 2008 12:31 Gary Wardell wrote: > Given the regex ^(.+)\@(.+?)$ I'm wondering if a really need the "gi", > since it's matching the whole string and it doesn't really care about case? > > Is "new" the preferred way to create regex objects or is it just better in > this case? No, you can use regular expression literals but you need to be aware of the consequences. In your sample you could drop the g flag and also, as already suggested, use the test method instead of the exec method. -- Martin Honnen http://JavaScript.FAQTs.com/
From: Gary Wardell on 24 Apr 2008 13:44 Hi, Yes, I came across that in looking for why it wasn't working. However, exec returns the captured strings in an array and I need to have the account separated from the domain name. I left that out to simplify the sample code. It's working now. Thanks, Gary
First
|
Prev
|
Pages: 1 2 Prev: Maintain a Div's Scroll Position After refresh Next: Tooltip text not showing |