Help in regular expression

K

Kimi

Hi,

I relatively new to perl and hence the regular expressions as well....

Can somebody help me understanding this re syntax, To be precise i need
to know what and all pattern the below expression matches to

if ($string =~ /^(ORA-[0-9]+):.*/ || $string =~ /.*[
]+(ORA-[0-9]+):.*/ || $string =~ /^(Corrupt block)/)

Thanks in advance
Fahad
 
J

John W. Krahn

Kimi said:
I relatively new to perl and hence the regular expressions as well....

Can somebody help me understanding this re syntax, To be precise i need
to know what and all pattern the below expression matches to

if ($string =~ /^(ORA-[0-9]+):.*/ || $string =~ /.*[
]+(ORA-[0-9]+):.*/ || $string =~ /^(Corrupt block)/)

$string =~ /
^ # match at the beginning of $string
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
.* # match zero or more of any character (except newline)
[ ]+ # match one or more space character
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
^ # match at the beginning of $string
( # start capturing here
Corrupt block # match the literal string 'Corrupt block'
) # end capturing
/x


John
 
K

Kimi

John said:
Kimi said:
I relatively new to perl and hence the regular expressions as well....

Can somebody help me understanding this re syntax, To be precise i need
to know what and all pattern the below expression matches to

if ($string =~ /^(ORA-[0-9]+):.*/ || $string =~ /.*[
]+(ORA-[0-9]+):.*/ || $string =~ /^(Corrupt block)/)

$string =~ /
^ # match at the beginning of $string
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
.* # match zero or more of any character (except newline)
[ ]+ # match one or more space character
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
^ # match at the beginning of $string
( # start capturing here
Corrupt block # match the literal string 'Corrupt block'
) # end capturing
/x


John


Thanks John, That helped a lot....
 
K

Kimi

John said:
Kimi said:
I relatively new to perl and hence the regular expressions as well....

Can somebody help me understanding this re syntax, To be precise i need
to know what and all pattern the below expression matches to

if ($string =~ /^(ORA-[0-9]+):.*/ || $string =~ /.*[
]+(ORA-[0-9]+):.*/ || $string =~ /^(Corrupt block)/)

$string =~ /
^ # match at the beginning of $string
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
.* # match zero or more of any character (except newline)
[ ]+ # match one or more space character
( # start capturing here
ORA- # match the literal string 'ORA-'
[0-9]+ # match one or more of the character in the range 0-9
) # end capturing
: # match the literal string ':'
.* # match zero or more of any character (except newline)
/x

$string =~ /
^ # match at the beginning of $string
( # start capturing here
Corrupt block # match the literal string 'Corrupt block'
) # end capturing
/x


John

Hi need a help in adding code to match,

"aiowait timed out" from the string which has "Warning: aiowait timed
out has occured 10 times"

with appreciation,
Kimi
 
J

Jim Gibson

Hi need a help in adding code to match,

"aiowait timed out" from the string which has "Warning: aiowait timed
out has occured 10 times"

if( $string =~ /Warning: aiowait timed out has occured (\d+) times/ ) {
# do stuff; number of timeouts in $1
}

Be sure and check the actual spelling of that error message (occurred?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top