In my continuing hell of international telephone numbers and notation habits I am now trying to strip out all the crud that I have to allow people to add here
This means I have to remove ' ', '(', ')' and '-'.
It seems that you can't nest REPLACE_PATTERN so is there another way, other than multiple REPLACE_PATTERN to cover each of the different patterns?
[SOLVED] REPLACE_PATTERN & Multiple Patterns
-
- Posts: 1457
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
[SOLVED] REPLACE_PATTERN & Multiple Patterns
Last edited by PointsWell on Tue May 29, 2018 7:19 am, edited 1 time in total.
Re: REPLACE_PATTERN & Multiple Patterns
Sean
Do you want me to write you a Java function to remove those 4 characters?
Contact.Phone = PHONE_STRIP(Contact.Phone)
if so, supply me with the working regular expression that achieves what you need.
jaymer...
Do you want me to write you a Java function to remove those 4 characters?
Contact.Phone = PHONE_STRIP(Contact.Phone)
if so, supply me with the working regular expression that achieves what you need.
jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: REPLACE_PATTERN & Multiple Patterns
What do you mean by that?PointsWell wrote: It seems that you can't nest REPLACE_PATTERN
I have used something like the following:
BO.NewAttr = REPLACE_PATTERN(REPLACE_PATTERN(BO.OldAttr, 'find1', 'replace1'), 'find2', 'replace2')
You still need multiple REPLACE_PATTERN statements, but they are inside each other and I call that nested.
More to a solution to your problem:
If you need to remove all non-numeric characters, you only need 1 REPLACE_PATTERN like:
BO.JustNumbers = REPLACE_PATTERN(BO.AlphaNumeric, '[\D]', '')
\D matches any non-digit
Bob
-
- Posts: 1457
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
Re: REPLACE_PATTERN & Multiple Patterns
It's little nuggets like this that make this forum such a powerful resource! And saves the very generous Jaymer from reinventing the wheel (though I was keen to have a peek inside the mystery that is Java to me). Now if only we could tag stuff in here better.BobK wrote: More to a solution to your problem:
If you need to remove all non-numeric characters, you only need 1 REPLACE_PATTERN like:
BO.JustNumbers = REPLACE_PATTERN(BO.AlphaNumeric, '[\D]', '')
\D matches any non-digit
-
- Posts: 1457
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
Re: REPLACE_PATTERN & Multiple Patterns
That was exactly what I was trying to achieve but it seems that one of the characters that I was trying to replace needed to be escaped - it was causing an error on the console.BobK wrote:What do you mean by that?PointsWell wrote: It seems that you can't nest REPLACE_PATTERN
I have used something like the following:
BO.NewAttr = REPLACE_PATTERN(REPLACE_PATTERN(BO.OldAttr, 'find1', 'replace1'), 'find2', 'replace2')
You still need multiple REPLACE_PATTERN statements, but they are inside each other and I call that nested.