Matching many when valid line exists


I am pulling my hair out trying to make a regex that will
1) Validate an entire line of input
2) Return any number of matches in the line

The condition is that any number of product codes must exist on a line
separated a space. It may or may not start or end with spaces. The
product code is a 10 digit number.

Example Valid Input:
"1234567890 0987654321 5678901234"

Current Expression:
/^[ ]([\d]{10}[ ])*([\d]{10})[ ]$/

This expression seems to validate well enough but, it only matches the
last two occurrences.

Any suggestions
Posted On: Sunday 4th of November 2012 10:56:39 PM Total Views:  135
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




Codegear sold : For how many U.S. dollars was sold ?

Hi For how many U.S. dollars was sold i have read : 23 MIL USD. but.... ONLY 23 mil. \t why
VIEWS ON THIS POST

140

Posted on:

Wednesday 3rd October 2012
View Replies!

FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.2: I'm having trouble matching over more than one line. What's wrong Either you don't have more than one line in the string you're looking at (probably), or else you aren't using the correct modifier(s) on your pattern (possibly). There are many ways to get multiline data into a string. If you want it to happen automatically while reading input, you'll want to set $/ (probably to '' for paragraphs or "undef" for the whole file) to allow you to read more than one line at a time. Read perlre to help you decide which of "/s" and "/m" (or both) you might want to use: "/s" allows dot to include newline, and "/m" allows caret and dollar to match next to a newline, not just at the end of the string. You do need to make sure that you've actually got a multiline string in there. For example, this program detects duplicate words, even when they span line breaks (but not paragraph ones). For this example, we don't need "/s" because we aren't using dot in a regular expression that we want to cross line boundaries. Neither do we need "/m" because we aren't wanting caret or dollar to match at any point inside the record next to newlines. But it's imperative that $/ be set to something other than the default, or else we won't actually ever have a multiline record read in. $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } Here's code that finds sentences that begin with "From " (which would be mangled by many mailers): $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /^From /gm ) { # /m makes ^ match next to \n print "leading from in paragraph $.\n"; } } Here's code that finds everything between START and END in a paragraph: undef $/; # read in whole file, not just one line or paragraph while ( ) { while ( /START(.*)END/sgm ) { # /s makes . cross line boundaries print "$1\n"; } } -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

125

Posted on:

Wednesday 3rd October 2012
View Replies!

regex back matching

I need to match on lines where the 4 quadrant of the ip is even with one line regex. For example, if I have 192.68.45.78 daskjaskjf asdfjkasjf asfkasfklh 192.68.34.62 ADKDAK Dkkslaslk jjsdkdldj 192.68.23 INEED HELP PLEASE 192.68.67.34 dkasdfkl kasfkasfkakf 192.68.4.97 flaskfk asfkfafv asf I should only get: 123.68.45.78 daskjaskjf asdfjkasjf asfkasfklh 192.68.34.62 ADKDAK Dkkslaslk jjsdkdldj 192.68.67.34 dkasdfkl kasfkasfkakf help and
VIEWS ON THIS POST

95

Posted on:

Tuesday 16th October 2012
View Replies!

regex question matching dates

John W. Krahn wrote: > Richard Lee wrote: >> >> @array = qx#ls -tr $directory/$ARGV[0]*#; > > Why not do that directly in perl: > > @array = map $_->[0], sort { $a->[1] $b->[1] } map [ $_, -M ], > glob "$directory/$ARGV[0]*"; Sorry, that should be: @array = map $_->[0], sort { $b->[1] $a->[1] } map [ $_, -M ], glob "$directory/$ARGV[0]*"; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall
VIEWS ON THIS POST

106

Posted on:

Tuesday 16th October 2012
View Replies!

copy the which is before ",(comma)" in one file and matching patternin another file

Problem Def: copy the pattern which before ",(comma)" and find a matching pattern in another file. status: i wrote following code. but it is not working properly. plz help me. #! C:\Perl\bin\perl.exe print "hello\n"; print "Please Enter Input File name(Give the complete path):"; $infile=; #give the input file name here chomp($infile); open ($in, "
VIEWS ON THIS POST

140

Posted on:

Wednesday 17th October 2012
View Replies!

FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.2: I'm having trouble matching over more than one line. What's wrong Either you don't have more than one line in the string you're looking at (probably), or else you aren't using the correct modifier(s) on your pattern (possibly). There are many ways to get multiline data into a string. If you want it to happen automatically while reading input, you'll want to set $/ (probably to '' for paragraphs or "undef" for the whole file) to allow you to read more than one line at a time. Read perlre to help you decide which of "/s" and "/m" (or both) you might want to use: "/s" allows dot to include newline, and "/m" allows caret and dollar to match next to a newline, not just at the end of the string. You do need to make sure that you've actually got a multiline string in there. For example, this program detects duplicate words, even when they span line breaks (but not paragraph ones). For this example, we don't need "/s" because we aren't using dot in a regular expression that we want to cross line boundaries. Neither do we need "/m" because we aren't wanting caret or dollar to match at any point inside the record next to newlines. But it's imperative that $/ be set to something other than the default, or else we won't actually ever have a multiline record read in. $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } Here's code that finds sentences that begin with "From " (which would be mangled by many mailers): $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /^From /gm ) { # /m makes ^ match next to \n print "leading from in paragraph $.\n"; } } Here's code that finds everything between START and END in a paragraph: undef $/; # read in whole file, not just one line or paragraph while ( ) { while ( /START(.*)END/sgm ) { # /s makes . cross line boundaries print "$1\n"; } } -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

119

Posted on:

Saturday 20th October 2012
View Replies!

FAQ 6.16 How do I efficiently match many regular expressions at once?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.16: How do I efficiently match many regular expressions at once ( contributed by brian d foy ) Avoid asking Perl to compile a regular expression every time you want to match it. In this example, perl must recompile the regular expression for every iteration of the foreach() loop since it has no way to know what $pattern will be. @patterns = qw( foo bar baz ); LINE: while( ) { foreach $pattern ( @patterns ) { if( /\b$pattern\b/i ) { print; next LINE; } } } The qr// operator showed up in perl 5.005. It compiles a regular expression, but doesn't apply it. When you use the pre-compiled version of the regex, perl does less work. In this example, I inserted a map() to turn each pattern into its pre-compiled form. The rest of the script is the same, but faster. @patterns = map { qr/\b$_\b/i } qw( foo bar baz ); LINE: while( ) { foreach $pattern ( @patterns ) { print if /$pattern/i; next LINE; } } In some cases, you may be able to make several patterns into a single regular expression. Beware of situations that require backtracking though. $regex = join '|', qw( foo bar baz ); LINE: while( ) { print if /\b(:$regex)\b/i; } For more details on regular expression efficiency, see Mastering Regular Expressions by Jeffrey Freidl. He explains how regular expressions engine work and why some patterns are surprisingly inefficient. Once you understand how perl applies regular expressions, you can tune them for individual situations. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

111

Posted on:

Saturday 20th October 2012
View Replies!

FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.2: I'm having trouble matching over more than one line. What's wrong Either you don't have more than one line in the string you're looking at (probably), or else you aren't using the correct modifier(s) on your pattern (possibly). There are many ways to get multiline data into a string. If you want it to happen automatically while reading input, you'll want to set $/ (probably to '' for paragraphs or "undef" for the whole file) to allow you to read more than one line at a time. Read perlre to help you decide which of "/s" and "/m" (or both) you might want to use: "/s" allows dot to include newline, and "/m" allows caret and dollar to match next to a newline, not just at the end of the string. You do need to make sure that you've actually got a multiline string in there. For example, this program detects duplicate words, even when they span line breaks (but not paragraph ones). For this example, we don't need "/s" because we aren't using dot in a regular expression that we want to cross line boundaries. Neither do we need "/m" because we aren't wanting caret or dollar to match at any point inside the record next to newlines. But it's imperative that $/ be set to something other than the default, or else we won't actually ever have a multiline record read in. $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } Here's code that finds sentences that begin with "From " (which would be mangled by many mailers): $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /^From /gm ) { # /m makes ^ match next to \n print "leading from in paragraph $.\n"; } } Here's code that finds everything between START and END in a paragraph: undef $/; # read in whole file, not just one line or paragraph while ( ) { while ( /START(.*)END/sgm ) { # /s makes . cross line boundaries print "$1\n"; } } -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

75

Posted on:

Saturday 20th October 2012
View Replies!

REx: ^ not matching after \n

(CC'd to Ilya) On Fri, December 14, 2007 11:34 pm, Ilya Zakharevich wrote: > Yet another (undocumented) quirk of REx engine: 5.8.8 docs say: > > You may, however, wish to treat a string as a multi-line > buffer, such that the "^" will match after any newline within the string, > and "$" will match before any newline. At the cost of a little more > overhead, you can do this by using the /m modifier on the pattern match > operator. > > It looks like "^" will never match at \z (=end of string), even if it > is after newline: That would match my mental expectation, where (m:^) means "start of line". You could quibble that "within" the string doesn't mean the last character, and the doc is correct as written, but I certainly want (m:^) to continue matching even after a newline-as-first-character. So the doc needs fixing. (The bit explaining /m does a better job, saying "matching the start...of any line anywhere within the string".) > P.S. I have no idea what info is attempted to be transmitted by "At > the cost of a little more overhead...". I read it approximately as: > > If you want to open file, use the open() function. On the > other hand, you can save a lot of overhead by skipping this call; your > program will behave as if the file does not exists, and will run much > quickier. I can see your point. I thought it was warning against needless use of /m when using ^, where the target string is known to not contain internal newlines. -- CollegeGear.com - more than just collegegear: http://ysth.perlmonk.org/initech/ (though, yes, we have college-branded teddy bears)
VIEWS ON THIS POST

73

Posted on:

Saturday 20th October 2012
View Replies!

Regular expression for matching words containing underscore _character

I have large text passages containing names of database tables, procedures, packages, variables etc having the underscore character as a part of the name. eg. rsp_names_friends_master. I tried "\b[a-zA- Z0-9_]+\b" but it matches all words in the passage.
VIEWS ON THIS POST

86

Posted on:

Saturday 20th October 2012
View Replies!

FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.2: I'm having trouble matching over more than one line. What's wrong Either you don't have more than one line in the string you're looking at (probably), or else you aren't using the correct modifier(s) on your pattern (possibly). There are many ways to get multiline data into a string. If you want it to happen automatically while reading input, you'll want to set $/ (probably to '' for paragraphs or "undef" for the whole file) to allow you to read more than one line at a time. Read perlre to help you decide which of "/s" and "/m" (or both) you might want to use: "/s" allows dot to include newline, and "/m" allows caret and dollar to match next to a newline, not just at the end of the string. You do need to make sure that you've actually got a multiline string in there. For example, this program detects duplicate words, even when they span line breaks (but not paragraph ones). For this example, we don't need "/s" because we aren't using dot in a regular expression that we want to cross line boundaries. Neither do we need "/m" because we aren't wanting caret or dollar to match at any point inside the record next to newlines. But it's imperative that $/ be set to something other than the default, or else we won't actually ever have a multiline record read in. $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } Here's code that finds sentences that begin with "From " (which would be mangled by many mailers): $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /^From /gm ) { # /m makes ^ match next to \n print "leading from in paragraph $.\n"; } } Here's code that finds everything between START and END in a paragraph: undef $/; # read in whole file, not just one line or paragraph while ( ) { while ( /START(.*)END/sgm ) { # /s makes . cross line boundaries print "$1\n"; } } -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

92

Posted on:

Saturday 20th October 2012
View Replies!

FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.2: I'm having trouble matching over more than one line. What's wrong Either you don't have more than one line in the string you're looking at (probably), or else you aren't using the correct modifier(s) on your pattern (possibly). There are many ways to get multiline data into a string. If you want it to happen automatically while reading input, you'll want to set $/ (probably to '' for paragraphs or "undef" for the whole file) to allow you to read more than one line at a time. Read perlre to help you decide which of "/s" and "/m" (or both) you might want to use: "/s" allows dot to include newline, and "/m" allows caret and dollar to match next to a newline, not just at the end of the string. You do need to make sure that you've actually got a multiline string in there. For example, this program detects duplicate words, even when they span line breaks (but not paragraph ones). For this example, we don't need "/s" because we aren't using dot in a regular expression that we want to cross line boundaries. Neither do we need "/m" because we aren't wanting caret or dollar to match at any point inside the record next to newlines. But it's imperative that $/ be set to something other than the default, or else we won't actually ever have a multiline record read in. $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } Here's code that finds sentences that begin with "From " (which would be mangled by many mailers): $/ = ''; # read in more whole paragraph, not just one line while ( ) { while ( /^From /gm ) { # /m makes ^ match next to \n print "leading from in paragraph $.\n"; } } Here's code that finds everything between START and END in a paragraph: undef $/; # read in whole file, not just one line or paragraph while ( ) { while ( /START(.*)END/sgm ) { # /s makes . cross line boundaries print "$1\n"; } } -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod. -- Posted via a free Usenet account from http://www.teranews.com
VIEWS ON THIS POST

102

Posted on:

Monday 22nd October 2012
View Replies!

advice on matching nested pattern?

sparkane writes: > Hi. Apologies in advance for the excessive English. I'm trying to > create a regex to be used as an interpolation symbol (hereafter > referred to as Symbol) for building webpage views. Here's the basic > regex for the Symbol: > > {{(/)\w+(: .+)((1)|/)}} > > The idea is that a string is submitted with any number of Symbols in > it. When a Symbol is found by the regex, another string is fetched > from storage and interpolated in place of the Symbol. The > interpolation is finished when there are no remaining Symbols, and the > view is sent to the client. My regex-fu isn't up to answering your actual question - sorry. :-( Having said that, it sounds like you're describing a template system. There are literally dozens of those on CPAN, from simple like Text::Template to extensive like Template Toolkit or Mason. Are you *really* sure that this particular wheel needs to be reinvented sherm-- -- Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
VIEWS ON THIS POST

77

Posted on:

Friday 26th October 2012
View Replies!

matching lines like grep

Noah wrote: > fellow PERL coders. > > I am trying to match lines between a template file and a configuration > file. If the configuration is missing a particular line that is found > in the template file then it is printed. If the configuration file has > an extra line then it to gets printed. > > Something isnt working here. I am not getting the lines to match an I > cant seem to figure out why. I am hoping somebody can shed some light here. It looks OK at first glance, but there could be many different problems, depending on what symptoms you are getting. First of all please use strict; use warnings; at the start of your code and declare all of your variables, then show us an example of the live data you have and the output you are getting. Could it be something as simple as not accounting for trailing whitespace on the records Rob , Rob Dixon wrote: > Noah wrote: >> in line Below >> >>>> let me put toether some bogus output files. >>> You could just describe your output. Are you getting nothing at all Or is it >>> showing all lines of both files Or none from one and all from the other Or >>> just more or fewer lines than you think is correct >>> >>> Remember that non-printable characters (whitespace for instance) may not match >>> even though it looks the same: spaces and tab characters for instance. >> looks like nothing matches. And when I open the files there is a "^M" >> at the end of each line. what would be the best approach to not pay any >> attention to the "^M" - search/replace >> >> When I capture the 'vim' man page and remove one line from one of the >> files - things work fine when there is white space all over the place as >> long as it matches. > > Then I guess you are processing a file that originated on a Windows system > Windows text files have a sequence at the end of each record, whereas > Unix files have just . is control-M, which is why vim is showing ^M at > the end of the line. > > What you need to do it to remove all whitespace from the end of lines after you > read them (from both the template and the config files) like this. > > @config_file_lines = ; > s/\s+$// foreach @config_file_lines; > Rob, okay the necessary line feed at the end of the line is disappearing. would it be better to something like: @config_file_lines = ; s/\s+$/\n/ foreach @config_file_lines; Cheers, Noah > That will remove and CR or LF characters as well as spaces and tabs (and FFs > actually) so that there are no line terminators at all and the record contents > can be compared properly. > > HTH, > > Rob
VIEWS ON THIS POST

111

Posted on:

Sunday 4th November 2012
View Replies!

get the matching regex pattern

I have a somewhat strange requirement I want to find if a regex matched what exactly matched to reproduce this ------------------ my @x; $x[0] = 'chi+ld*'; $x[1] = '\sjoke'; $_=getinput(); # for test assume $_="This is a joke"; if(/($x[0]|$x[1])/){ print "Matched '$1' \n"; } ----------------- I want to know if $x[0] matched or $x[1] matched What is the most efficient way of doing this
VIEWS ON THIS POST

83

Posted on:

Sunday 4th November 2012
View Replies!

Pattern matching problem

Dear List I have a very large file basically it is logfile generated by sql loader......... In the production environment this file can have one million/ two million data. In this file there are 4 particular lines which i need to extract from this log file. *Total logical records skipped: 0 Total logical records read: 4830 Total logical records rejected: 51 Total logical records discarded: 4760 * These four lines stayed at the bottom of the. Now if I use a filehandel to open the file and stored it contents in an array and after that I make a search to find these 4 lines then it will take lot of times to get output. So is there any other way where I dont need to store the file in a array and I can directly search the file and when I find these lines I can store these lines in some array or variables. I am pesting part of the file here. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL*Loader: Release 9.2.0.1.0 - Production on Tue Feb 5 10:58:04 2008 Copyright (c) 1982, 2002, Oracle Corporation. rights reserved. Control File: FINAL.ctl Data File: FINAL.DAT Bad File: FINAL.bad Discard File: FINAL.dsc (ow all discards) Number to load: ALL Number to skip: 0 Errors allowed: 50 Bind array: 64 rows, maximum of 256000 bytes Continuation: none specified Path used: Conventional Table DIM_DIAL_DIGIT, loaded when ISO_COUNTRY_CODE = 0X54554e(character 'TUN') Insert option in effect for this table: APPEND Column Name Position Len Term Encl Datatype ------------------------------ ---------- ----- ---- ---- --------------------- DIAL_DIGIT_KEY FIRST * ; O(") CHARACTER BU_KEY NEXT * ; O(") CHARACTER NULL if BU_KEY = 0X4e554c4c(character 'NULL') NOP_ID_KEY NEXT * ; O(") CHARACTER SDCA_LOCATION_CODE NEXT * ; O(") CHARACTER TARGET_REGION_DESC NEXT * ; O(") CHARACTER TARGET_COUNTRY_CODE NEXT * ; O(") CHARACTER NULL if TARGET_COUNTRY_CODE = 0X4e554c4c(character 'NULL') TARGET_COUNTRY_DESC NEXT * ; O(") CHARACTER LDCA_NAME NEXT * ; O(") CHARACTER SDCA_NAME NEXT * ; O(") CHARACTER LDCC_X_COORD NEXT * ; O(") CHARACTER NULL if LDCC_X_COORD = 0X4e554c4c(character 'NULL') LDCC_Y_COORD NEXT * ; O(") CHARACTER NULL if LDCC_Y_COORD = 0X4e554c4c(character 'NULL') SDCC_X_COORD NEXT * ; O(") CHARACTER NULL if SDCC_X_COORD = 0X4e554c4c(character 'NULL') SDCC_Y_COORD NEXT * ; O(") CHARACTER NULL if SDCC_Y_COORD = 0X4e554c4c(character 'NULL') POPULATION_DATE_TIME NEXT * ; O(") DATE MM/DD/YYYY HH24:MI:SS NULL if POPULATION_DATE_TIME = 0X4e554c4c(character 'NULL') ISO_COUNTRY_CODE NEXT * ; O(") CHARACTER HOTLIST_IND NEXT * ; O(") CHARACTER BLACKLIST_IND NEXT * ; O(") CHARACTER UPDATE_DATE_TIME NEXT * ; O(") DATE MM/DD/YYYY HH24:MI:SS NULL if UPDATE_DATE_TIME = 0X4e554c4c(character 'NULL') EVENT_TYPE_KEY NEXT * ; O(") CHARACTER NULL if EVENT_TYPE_KEY = 0X4e554c4c(character 'NULL') PROVIDER_DESCRIPTION NEXT * ; O(") CHARACTER DM_IND NEXT * ; O(") CHARACTER DIAL_DIGIT_OPERATOR_TYPE NEXT * ; O(") CHARACTER CALL_DIRECTION_KEY NEXT * ; O(") CHARACTER NULL if CALL_DIRECTION_KEY = 0X4e554c4c(character 'NULL') DIAL_DIGIT_DESCRIPTION NEXT * ; O(") CHARACTER Record 1: Discarded - failed all WHEN clauses. FORCE_RI_IND NEXT * ; O(") CHARACTER TEST_CALL_IND NEXT * ; O(") CHARACTER Record 1: Discarded - failed all WHEN clauses. Record 2: Discarded - failed all WHEN clauses. Record 3: Discarded - failed all WHEN clauses. Record 4: Discarded - failed all WHEN clauses. Record 5: Discarded - failed all WHEN clauses. Record 6: Discarded - failed all WHEN clauses. ....................................... .......................................... ............................................. Record 482500: Discarded - failed all WHEN clauses. Record 485001: Discarded - failed all WHEN clauses. Record 485002: Discarded - failed all WHEN clauses. Record 485003: Discarded - failed all WHEN clauses. Record 485004: Discarded - failed all WHEN clauses. Record 231: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated ......................................... ............................................. Record 232: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated Record 233: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated Record 234: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated Record 235: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated Record 236: Rejected - Error on table DIM_DIAL_DIGIT. ORA-00001: unique constraint (SCOTT.SYS_C003608) violated MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run. Table DIM_DIAL_DIGIT: 0 Rows successfully loaded. 51 Rows not loaded due to data errors. 4760 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. Space allocated for bind array: 254904 bytes(38 rows) Read buffer bytes: 1048576 *Total logical records skipped: 0 *--------->* Total logical records read: 4830 Total logical records rejected: 51 Total logical records discarded: 4760 -------> these are the four lines i need to extract.* Run began on Tue Feb 05 10:58:04 2008 Run ended on Tue Feb 05 10:58:04 2008 Elapsed time was: 00:00:00.28 CPU time was: 00:00:00.11
VIEWS ON THIS POST

84

Posted on:

Sunday 4th November 2012
View Replies!

matching a high range of numbers.

thanks feherke, i suppose i was assuming there was a more elegant solution available out there but maybe not... incidently i'm not sure some of those possible solutions really work for instance the problem i have with using [] ranges is that it'll match 200, 2000, 200000 etc and the last one doesnt work at all, for me anyways.. it'll match 200 but nothing else. , also just so people don't think i'm being silly for not using a simple numerical comparison, the actual problem is more complex as i'm trying to match on a set of numbers inside of a larger string and rather than extract that one piece of the string to do a comparison on i was wondering if i could integrate it altogether.
VIEWS ON THIS POST

95

Posted on:

Sunday 4th November 2012
View Replies!

Trying to catch invalid emails

, I use the following regular expression to catch typical invalid email addresses: ------------ my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org"); foreach (@Email) { if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)\.[A-z]{2,3}$/) { print "$_ is a valid email id\n"; } else { print "$_ is an invalid email id\n"; } } ------------- This expression does not catch the above 3 emails in the array (the program says that they are valid emails). Can someone help me to discard these three
VIEWS ON THIS POST

70

Posted on:

Sunday 4th November 2012
View Replies!

FAQ 6.16 How do I efficiently match many regular expressions at once?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 6.16: How do I efficiently match many regular expressions at once ( contributed by brian d foy ) Avoid asking Perl to compile a regular expression every time you want to match it. In this example, perl must recompile the regular expression for every iteration of the "foreach" loop since it has no way to know what $pattern will be. @patterns = qw( foo bar baz ); LINE: while( ) { foreach $pattern ( @patterns ) { if( /\b$pattern\b/i ) { print; next LINE; } } } The "qr//" operator showed up in perl 5.005. It compiles a regular expression, but doesn't apply it. When you use the pre-compiled version of the regex, perl does less work. In this example, I inserted a "map" to turn each pattern into its pre-compiled form. The rest of the script is the same, but faster. @patterns = map { qr/\b$_\b/i } qw( foo bar baz ); LINE: while( ) { foreach $pattern ( @patterns ) { if( /$pattern/ ) { print; next LINE; } } } In some cases, you may be able to make several patterns into a single regular expression. Beware of situations that require backtracking though. $regex = join '|', qw( foo bar baz ); LINE: while( ) { print if /\b(:$regex)\b/i; } For more details on regular expression efficiency, see *Mastering Regular Expressions* by Jeffrey Freidl. He explains how regular expressions engine work and why some patterns are surprisingly inefficient. Once you understand how perl applies regular expressions, you can tune them for individual situations. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

89

Posted on:

Sunday 4th November 2012
View Replies!

Trying to catch invalid emails

, I use the following regular expression to catch typical invalid email addresses: ------------ my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org"); foreach (@Email) { if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)\.[A-z]{2,3}$/) { print "$_ is a valid email id\n"; } else { print "$_ is an invalid email id\n"; } } ------------- This expression does not catch the above 3 emails in the array (the program says that they are valid emails). Can someone help me to discard these three
VIEWS ON THIS POST

141

Posted on:

Sunday 4th November 2012
View Replies!