mercredi 28 mai 2014

String Manipulation with Regular Expression specifically or statements


Vote count:

0




I am trying to parse out certain strings from a phrase. This is the phrase: '1st Floor 2nd Floor 3rd Floor 4th Floor' The end phrase should be: '1st Floor','2nd Floor','3rd Floor','4th Floor'


I am having trouble getting the '1st','2nd','3rd','4th' parts of the regex. I know I can do a less-intuitive version by using 4 different or statements but I am wondering if I can do it with one.


'\dst\s\w+|\dnd\s\w+|\drd\s\w+|\dth\s\w+' - this is the long way that i am trying to shorten


Is there anyway to combine the st,nd,rd,and th into one statement without repeating the formatting after? Thanks.



asked 47 secs ago






Aucun commentaire:

Enregistrer un commentaire