Avatar of thota198
thota198

asked on 

regarding regexp

wht is the below code tell can anyone explain

 REGEXP_REPLACE (io_message_body,
                         '(^|\W)' || LOWER ('<BODY>') || '(\W|$)',
                         '\1' || LOWER ('<BODY>' || v_message_body) || '\2',
                         1,
                         0,
                         'i'
                        );
Oracle Database

Avatar of undefined
Last Comment
thota198
Avatar of Qlemo
Qlemo
Flag of Germany image

That is a bit confusing on first glance, as || is the Oracle string concatenation operator, and | is "OR" in regexp. We can simplify the first part:

 REGEXP_REPLACE (io_message_body,
                         '(^|\W)<body>(\W|$)',
                         '\1' || LOWER ('<BODY>' || v_message_body) || '\2',
                         1, 0, 'i'
                        );

So, the search string is a start-of-line (^) or (|) non-word character (\W) [not: 0-9, A-Z, a-z, underscore], folllowed by <body>, and a non-word-character or end-of-line ($).
This is then replaced with: first group found (\1) [a group is a regexp in parens], that is the non-word character or start-of-line, then body tag is extended by some text, followed by the second group.

Or short: replace "<body>" with "<body>SomeMessageBody" by retaining a optional non-word character prefixing and/or suffixing the "<body>" tag, but that tag needs to stand on an own line.

I hope that was less confusing, but regexp aren't easy to understand ... A reference can be found at http://en.wikipedia.org/wiki/Regular_expression  (and many other locations).
ASKER CERTIFIED SOLUTION
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of thota198
thota198

ASKER

thanks a lot
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo