Adobe Dreamweaver Forums



Last 10 THreads :         Help with navigation (Last Post : Jiva Mukta - Replies : 0 - Views : 1 )           »          Why is this not working!!! (Last Post : Boxing Boom - Replies : 3 - Views : 4 )           »          CSS: Mystery IE and Firefox issue (Last Post : Codesonic - Replies : 0 - Views : 1 )           »          Update scrollbar on text area? (Last Post : Handycam - Replies : 0 - Views : 1 )           »          debugger causing browser to crash (Last Post : thmunson - Replies : 4 - Views : 5 )           »          Passing variable between components (Last Post : Amy Blankenship - Replies : 3 - Views : 4 )           »          Flash Slide Presentation and CS4 motion tween (Last Post : pivovar - Replies : 0 - Views : 1 )           »          Please point me to the correct topic section of thisForum (Last Post : dzedward - Replies : 9 - Views : 10 )           »          Cookies and cflogin (Last Post : idesdema - Replies : 7 - Views : 9 )           »          left join won't work in query of query? (Last Post : Amm85 - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 02:57 PM
nikos101
 
Posts: n/a
Diggs:
Default Regex to check if there is a string inside anotherstring

What is the best regex to check if there is a string inside another string?

This doesn't work:

var regex:RegExp = new RegExp("/^.+" + myString + ".+$/");


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-03-2008, 11:40 AM
nikos101
 
Posts: n/a
Diggs:
Default Re: Regex to check if there is a string inside anotherstring

Thanks Greg your code is fine.

However I just can't seem to get these regex to work in my other code:

var st:String = addcurrencyInput.text;
if(addcurrencyInput.text.length == 0){
Alert.show("You cannot add a blank currancy");
}
else if(!st.search(new RegExp("/^[0-9]+$/"))){
Alert.show("The currancy may only contain alphabetical characters");
}
else{
myService.addCurrency(addcurrencyInput.text);
}

the following line never gets excecuted regarless of the text inside st

Alert.show("The currancy may only contain alphabetical characters");


Reply With Quote
  #3 (permalink)  
Old 10-03-2008, 05:22 PM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Regex to check if there is a string inside anotherstring

else if(st.search(regex) == -1)

If the search fails, the return value is -1, not false or 0.
Reply With Quote


  #4 (permalink)  
Old 10-03-2008, 05:35 PM
nikos101
 
Posts: n/a
Diggs:
Default Re: Regex to check if there is a string inside anotherstring

Dude you have made me a very happy man, I was worried about my boss getting impatient
Reply With Quote
  #5 (permalink)  
Old 10-03-2008, 06:02 PM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Regex to check if there is a string inside anotherstring

Just remember to always check the FB3 help sys for relevant aspects of the
problem at hand. I checked the return value for the search method of the String
class. This is often how I solve these posts for people.

Reply With Quote
Reply


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

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



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 07:46 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk