I am badly in need to write a regular expression which replaces dots or single spaces inside of particular sub strings in a string. Suppose the string that I want to parse is something like 'AB.C$. WFD.C!-' . Now the reg ex should essentially convert it to 'ABC$. WFD.C!-' i.e. if a space and dot comes in between AB and C or precede or succeed them then only they should be replaced. Please help me through .
Asked
Active
Viewed 565 times
1
-
I do not want to replace case by case scenarios like 'AB.c.' or 'AB c.' or 'AB c ' to 'ABc'. I desperately want it to be done via reg ex. Please explain me the steps also. – StrugglingCoder Mar 19 '15 at 10:51
1 Answers
2
What about this:
SELECT REGEXP_REPLACE('AB.C$. WFD.C!-', 'A(\.| )B', 'AB', 1, 0, 'c');
It will remove all literal dots and spaces between A
and B
starting at position 1 in the input string, and will replace all occurrences (0
argument),
and 'c'
means case sensitive matching.
Read more about the teradata regex syntax here.

Wiktor Stribiżew
- 607,720
- 39
- 448
- 563