Hi, anybody can help me with this ? I check VAT numbers calling an API that returns a JSON where in the “address field” there are special characters like \n that separate the address in two lines. This is an example of the raw data that I get from the API call:
“address”: “street and number \nzip code city state\n”
What I would like to achieve is to fill at least two diffeterent input elements on the page, like INPUT STREET ADDRESS and INPUT CITY STATE, so that user can then save to DB in the corresponding fields.
Doing some research I found that I have probably to use regular expression to do this, but have no idea how to do it. This is a test I am doing with a text element.
HI @simon7, I tried this for extracting the address (first line). Can you confirm that the syntax is right ? or maybe I should have changed the * with something else. Consider that I do not have a clue of what I am doing …
From the looks it seems that this could work instead:
first: (.*)\n
second: \n(.*)
Short explanation: We try to extract whatever is inside the ( ). Here we have a “dot” which means every character, and the * means zero-to-unlimited times. The \n works as a delimiter. In the first example we try to get whatever is before a newline character, and in the second we extract whatever comes after the newline character. If, for example you only wanted to extract numbers it could be written like (\d*)\n as “\d” means “any number” in regex-language
Btw. after the regex add a “trimmed” to remove unintentional spaces.
If this doesnt work, is it possible for you to share the api? Regex can be stupidly hard to get right without the source. Otherwise you could share the raw result from api connector (api connector → initialize → show raw data).