The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

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

asked 26 Jan '10, 12:09

Thomas%20Duemesnil's gravatar image

Thomas Dueme...
2.4k203357
accept rate: 16%

I second this proposal for similar reasons.

(26 Jan '10, 13:36) Volker Barth

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.

permanent link

answered 26 Jan '10, 12:45

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262
accept rate: 40%

1

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.

(27 Apr '11, 21:01) Ron Hiner

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

(27 Apr '11, 23:07) Graeme Perrow
Replies hidden

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

(28 Apr '11, 03:27) Volker Barth
2

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.

(25 Jan '13, 09:58) Jeff Albion
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×106
×3

question asked: 26 Jan '10, 12:09

question was seen: 1,933 times

last updated: 16 Dec '15, 09:50