on 2010 Jan 26 12:09 PM
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
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
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Obligatory xkcd reference: http://xkcd.com/208/
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.
User | Count |
---|---|
74 | |
20 | |
9 | |
8 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.