Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team
I have a requirement where the data is something like 010.040.103.222.1234.000 and the expected output should be
010.103.222.1234000. The basic idea is from the input i have to remove 5-8 characters (i.e, 040.) and in the last i.e. 20th position i have to remove '.'
input: 010.040.103.222.1234.000
expected output: 010.103.222.1234000
Any idea team! Appreciate your help.
Thanks & Regards
Krishu
ok first i replace a (dot followed by 1 to 3 digits) preceded by 1 to 3 digits a the bergining of the string (Lookbehind regex expression)
then i replace a dot followed by 1 to 3 digits a the end of the string (Lookahead regex expression)
https://www.regular-expressions.info/lookaround.html for more info about Lookbehind and Lookahead
^ is for begining of the string
$ is for end of he string
HI , (your string).replaceAll("(?<=(^\\d{1,3}))(\\.\\d{1,3})","").replaceAll("\\.(?=\\d{1,3}$)","")
Send me Love and Kudos
Hi gjeremy1617088143
Thank you soo much😉 it worked, but could you explain what exactly u have written in the logic. It looks like regex but I don't how regex works..
Thanks & Regards
Krishu
ok first i replace a (dot followed by 1 to 3 digits) preceded by 1 to 3 digits a the bergining of the string (Lookbehind regex expression)
then i replace a dot followed by 1 to 3 digits a the end of the string (Lookahead regex expression)
https://www.regular-expressions.info/lookaround.html for more info about Lookbehind and Lookahead
^ is for begining of the string
$ is for end of he string
Thank you very much😀 😍