monkeytooth Posted November 23, 2009 Share Posted November 23, 2009 I am tempting to filter my form inputs with jquery. I am currently playing with RegExp. But I am noticing I am limiting myself a bit. Some of the fields like the Address Fields for example need the ability to have a space between things. example: "123 MyStreet Rd." However from my poking around I can't come across a regexp format that will allow things like . and [space], nor can i think of one on my own. Needless to say I am a bit stuck. Is anyone able to help me on this? RegExp('[^a-zA-Z]+', 'g'); val = val.replace(pattern, ''); var pattern = new RegExp('[^0-9a-zA-Z]+', 'g'); val = val.replace(pattern, ''); Above are the 2 things I am using right now. One to allow strickly alphabetic input and one to allow a combination of alpha and numeric. But how to add a space or a period or a comma in the expression I don't know. I am lost, any help would cool. Quote Link to comment https://forums.phpfreaks.com/topic/182613-regexp-with-space-allowed/ Share on other sites More sharing options...
monkeytooth Posted November 23, 2009 Author Share Posted November 23, 2009 http://www.lousyllama.com/blog/jquery-autotab-11-beta-ready-testing#comment-288 is the script I am working with. I am attempting to use its "Custom" filter while attempting to build my own regexp to verify if a street address is good or not I have spent several hours prior to this original post and after trying various ways of putting a regexp together for this and have failed each time. I am no good with this regexp stuff. Can anybody help me with this, I can't move on in my project til i solve this cause I have OCD, and its beyond me. I just want a means to handle "123 Some St." that can also accept the following with or without the dot, with or without a hyphen, with or without a #, with or without a comma, with a space. anyone able to help me out here? please? I can't be stuck on this for days and days. This is most likely something simple to anyone who knows regexp better than I. Quote Link to comment https://forums.phpfreaks.com/topic/182613-regexp-with-space-allowed/#findComment-963861 Share on other sites More sharing options...
salathe Posted November 23, 2009 Share Posted November 23, 2009 In simple terms you can extend the character class ([…]) with the extra characters that you want to allow, for example [^0-9a-zA-Z.#, -]+ If you need stricter checking (the above would allow #.......,,,----### as a valid address) do let us know more precisely what you're willing to allow/deny. Quote Link to comment https://forums.phpfreaks.com/topic/182613-regexp-with-space-allowed/#findComment-963864 Share on other sites More sharing options...
monkeytooth Posted November 23, 2009 Author Share Posted November 23, 2009 Allow: . , - # 0-9 a-z A-Z [spacebar] Deny: anything that's not above Quote Link to comment https://forums.phpfreaks.com/topic/182613-regexp-with-space-allowed/#findComment-964089 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.