boblawblah has asked for the wisdom of the Perl Monks concerning the following question:
Now I expect to be able to say:<TABLE name="table1"> FieldName1 VARCHAR(20) FieldName2 INT(20) FieldName3 BOOL </TABLE> <TABLE name="table"2> FieldName1 VARCHAR(20) FieldName2 INT(20) FieldName3 BOOL </TABLE>
What I get is nothing. When I saywhile ($file =~ s/<TABLE(.*)>([\n.]*)<\/TABLE>//i) { # $1 should equal ' name="table1"' my $attributes = $1; #$2 should equal # #FieldName1 VARCHAR(20) #FieldName2 INT(20) #FieldName3 BOOL # my $fields = $2; }
Then$file =~ s/<TABLE(.*)>(\n.*)//i
- the first line of text. Or:$2 = 'FieldName1 VARCHAR(20)'
Then$file =~ s/<TABLE(.*)>([\n.]*)//i\
I know that the . (wildcard) charcater doesn't match newlines, hence using the character class \n. in my original example - does anyone have an answer as to why this doesn't work, and what should I do instead? Thank you!$2 = "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex, Newline, Wilcard
by ikegami (Patriarch) on Jan 27, 2009 at 22:32 UTC | |
|
Re: Regex, Newline, Wilcard
by kyle (Abbot) on Jan 27, 2009 at 21:47 UTC | |
by ikegami (Patriarch) on Jan 27, 2009 at 22:28 UTC | |
|
Re: Regex, Newline, Wilcard
by shmem (Chancellor) on Jan 27, 2009 at 22:58 UTC | |
|
Re: Regex, Newline, Wilcard
by hbm (Hermit) on Jan 27, 2009 at 23:59 UTC | |
|
Re: Regex, Newline, Wilcard
by JavaFan (Canon) on Jan 28, 2009 at 09:36 UTC |