I am trying to write simple function in JAVASCRIPT which can customize my html code with Tampermonkey installed on my chrome web browser. My input html is an address:
'John OConnor<br><br>
Shop St 7<br>
Dublin<br>
12<br>
IE'
This address is saved in my variable named "address". I used some code to customize it:
address = address.replace(/<br><br>/gi, '<br>'); //remove duplicated <br> tag
address = address.replace(/St/gi, 'Street'); //change st to street
address = address.replace(/IE/gi, 'Ireland'); //change IE to Ireland
now my html output looks like this:
'John OConnor<br>
Shop Street 7<br>
Dublin<br>
12<br>
Ireland'
my question now is how to write a code to move that "12" to get "Dublin 12"? I was trying this code:
address = address.replace(/<br>\d\d<br>/gi, '\d\d<br>')
\d = return any digit
but it returns: "Dublin \d\d" and I want "Dublin 12"
hope you understand. any idea?
Brien Fieldsand it becomesBrIrelandn FIrelandldsor if the name isSteve Stobartand it becomesStreeteve Streetobart?.replace(/<br>IE<br>/gi, '<br>Ireland<br>')dublin<br>co dublin<br>dublin d12<br>default<br>irelandoutput:Dublin 12<br>Ireland