Regex patterns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regex patterns
# 1  
Old 11-19-2014
Regex patterns

can someone please confirm for me if i'm right:

the pattern:

Code:
ORA-0*(600?|7445|4[0-9][0-9][0-9])[^0-9]

can someone give me an idea of all the entries the pattern above will grab from a database log file?

is it looking for the following strings?:
Code:
ORA-0600
ORA-7445
4[0-9][0-9][0-9])[^0-9]

# 2  
Old 11-19-2014
Let's break it down.

Code:
ORA- # String must begin in this
         0*    # Zero or more zeroes, i.e. 600, 0600, 0000000000600...
         # And one of the following:
                600?  # 60 or 600
                7445 # this exact string
                4[0-9][0-9][0-9] # 4000-4999
         # Followed by at least one non-numeric character:
        [^0-9]

So it's hard to tell if any of those would work. That non-numeric doesn't seem to have anything to match.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 11-19-2014
Why "at least one non-numeric char"? Shouldn't that be exactly one non-numeric char?

So, the matches would be for example
Code:
    |0|60  |=
    | |600 |A
ORA-|0|7445|Z 
    | |4000|a
    | |4999|z

Use all the column entries interchangeably, with space representing "empty". Trying to be picturesque is not THAT easy, in this case.

---------- Post updated at 21:11 ---------- Previous update was at 21:05 ----------

Quote:
Originally Posted by SkySmart
. . .
is it looking for the following strings?:
Code:
ORA-0600                  # No
ORA-7445                  # No
4[0-9][0-9][0-9])[^0-9]   # No

But:
Code:
ORA-0600%                  # Yes
ORA-60{                    # Yes
ORA-7445a                  # Yes
ORA-07445Z                 # Yes
ORA-04091~                 # Yes

Show some input strings that we can try to build a regex for.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Regarding a GREAT site for understanding and Visualizing regex patterns.

Hello All, While googling on regex I came across a site named Regulex Regulex:JavaScript Regular Expression Visualizer I have written a simple regex ^(a|b|c)(*)@(.*) and could see its visualization; one could export it too, following is the screen shot. ... (3 Replies)
Discussion started by: RavinderSingh13
3 Replies

2. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies

3. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

4. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

5. Shell Programming and Scripting

Find matched patterns and print them with other patterns not the whole line

Hi, I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
Discussion started by: redse171
3 Replies

6. Shell Programming and Scripting

Question about REGEX Patterns and Case Sensitivity?

Hello All, I'm in the middle of a script and I'm doing some checks with REGEX (i.e. using the '"shopt -s nocasematch" that at least the first one should print "FALSE" but it prints "TRUE"..? For Example: #!/bin/bash MY_VAR="HELLO" ### This prints "TRUE" PATTERN_1="^*" if ] then... (5 Replies)
Discussion started by: mrm5102
5 Replies

7. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

8. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

9. Shell Programming and Scripting

Capture values using multiple regex patterns

I have to read the file, in each line of file i need to get 2 values using more than one search pattern. ex: <0112 02:12:20 def > /some string/some string||some string||124 i donot have same delimiter in the line, I have to read '0112 02:12:20' which is timestamp, and last field '124' which is... (4 Replies)
Discussion started by: adars1
4 Replies

10. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies
Login or Register to Ask a Question