purencool Posted October 23, 2009 Share Posted October 23, 2009 Hi phpfreaks This code should either find a . anywhere in the string to return nothing. Else add . to the end. I can not get it to work. Can any one see why? thanks purencool var mores = win.search(/./) alert(mores) if( mores != -1 || 0){ var returnValue = win; }else{ returnValue = (win += ".") ; } return returnValue; Quote Link to comment Share on other sites More sharing options...
Adam Posted October 23, 2009 Share Posted October 23, 2009 Think your problem's here.. if( mores != -1 || 0){ Should just be: if (mores != -1) { Remember 0 is a valid match. Also if you were wanting to check against -1 or 0, you'd need to use: if( mores != -1 || more != 0){ Quote Link to comment Share on other sites More sharing options...
purencool Posted October 23, 2009 Author Share Posted October 23, 2009 You were right thanks I don't what I was thinking when I wrote that. But my issue was the regex and full stop. This fixed it. var mores = win.search(/[.]/); if( mores != -1){ var returnValue = win; }else{ returnValue = (win += ".") ; } return returnValue; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.