javascript regular expression parsing ip address from a string



How can I parse a string using regular expression in javascript. I will get this string below. (I only need the regular expression.)


Lets called this string access_indicator and ip address combined



RCHLMI55---01CAB101A-71.151.193.98
TROZMIYZ---01CAB101A-71.151.193.54
RCHLMI59---01CAB101A-71.151.193.99
TROAMIAM---01CAB101A-71.151.193.101
Future_7330


I need to parse only ip addresses. I try using \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b to get the ip address but i got an error



ERROR - sbc.cms.xml.XMLException: <input> element #1's ip_addr <field> element(#20) must have at least one capturing group in the regular expression of its edit attribute.


Also, I need to get the access indicator and parse it as it is below, sometimes it won't have an ip address when it doesn't have an ip address i can keep the whole access indicator string:



RCHLMI55---01CAB101A
TROZMIYZ---01CAB101A
RCHLMI59---01CAB101A
TROAMIAM---01CAB101A
Future_7330


@bytebender posting the rest of the code below, we are using xml to parse it



<field name="ip_addr" count="16" delimiter="{_csv_}" edit="re=\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" allow-blank="yes" />

No comments:

Post a Comment