Hi all, I want to know if anyone could help me on a string issue I’m having. I get data from a mainframe that is returning a string with some special characters in it. See below
John Doe ?z1234563? Sally D ?1053442233?
1.) I want to remove the second “?” after John Doe
Can someone help me on this? I’m having a very hard time.
On the face of it, the following code will do what you want, but I'm wondering whether the codes can be any length and you'd like them truncated from the left to seven characters. I'm having some difficulty in working out more exactly what the problem is that you're wanting to solve. (this code doesn't exclude those lines that don't have eight consecutive numbers after the '?'. you'd do a LIKE with the same wildcard)
answered Aug 15 '11 at 03:14 AM
You can do any pattern matching and replacement easy by CLR RegEx implementation.
You can take a look on the sample implementation SQL Server Regular Expressions – Replacements.
If I understand it exactly as @Magnus Ahlkvist in the comment, then using the above implementation, you can easily run below code:
If you need other results, it's only a question of passing right Regular Expressions.
answered Aug 12 '11 at 12:12 PM