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; Link to comment https://forums.phpfreaks.com/topic/178704-solved-code-issue-0-1/ 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){ Link to comment https://forums.phpfreaks.com/topic/178704-solved-code-issue-0-1/#findComment-942810 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; Link to comment https://forums.phpfreaks.com/topic/178704-solved-code-issue-0-1/#findComment-943209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.