cancel
Showing results for 
Search instead for 
Did you mean: 

Please implement REGEXP_REPLACE

thomas_duemesnil
Participant
6,552

When i need to validate user input in fields it is often necessary to make sure only a limited set of characters is used.

Example could be European VAT Numbers, Phone, Container ID Code ...

The current REGEXP_SUBSTR Function is not able to match several accurencase of a given pattern in one go.

Syntax

REGEXP_REPLACE( expression, regular-expression 
[, start-offset [ , occurrence-number [, escape-expression
[, regex-parameter ] ] ] ] )

Parameters

  • Like REGEXP_SUBSTR
  • regexp-paramter g Global search; i Case Insensitive; ....

Samples :

// In JScript they use a RegEx Parameter **g** to use the RegEx globaly against the
// searchstring 
regexp_replace( "0049-282 8/182", "[^0-9]", "") --> "00492828182"

// With grouped tagged expression to use in replacement string
regexp_replace( "0049 282 8182", "^00(\\S*) (\\S*) (.*)", "+$1 \\($2) $3") --> "+49 (282) 8182"

Oracle also has a implementation of it http://download.oracle.com/docs/...

See this Question to see more reasons to implement REGEXP_REPLACE

Accepted Solutions (1)

Accepted Solutions (1)

MarkCulp
Participant

This is another one of those features that we have discussed within the engineering team on several occassions. I too have had many times that I've wanted to do be able to find a pattern within a string and replace it with a different one. But alas, regular expressions are complicated not only to understand and use but to implement and perform well. As such, this feature is already on the list of possible enhancements to be put into a future release.

Former Member

I agree Mark! Regular expressions are complicated. It's my humble opinion that the purpose of any computer code, wether it be SQL, Java, PHP, Powerbuilder, or any other language, is for HUMANS to read and manage -- not computing systems... it's the systems' job to translate that code into something that they can deal with. While I fully appreciate the power of regex, I hate everything about it... precisely because it's incomprensible for many of us mortals.

graeme_perrow
Advisor
Advisor
0 Kudos

Obligatory xkcd reference: http://xkcd.com/208/

VolkerBarth
Contributor
0 Kudos

...and don't forget to look at the tool tip:)

jeff_albion
Product and Topic Expert
Product and Topic Expert

I should add that this similar topic was discussed as part of this question here, and was noted as part of the formatting enhancement opportunities in CR #728186.

Answers (0)