Do you mean you wish to ignore all lines which either have only the string "case :" or start with a colon or start with the string "struct" and put that in one regex?If so, this will work: use Modern::Perl;
while (<DATA>) {
next if /^\s*case :$|^:|^struct/;
print;
}
__DATA__
case :
case :
case : keep me
: ignore this
keep this line
struct: get rid of me
struct: but keep me
By the way, your regex will also ignore lines which have anything between "case" and the colon. That does not seem to conform to your requirement.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James My blog: Imperial Deltronics
| [reply] [d/l] [select] |
<expression>^\s*case\s+.*?:\s*$</expression>
the abvove lines in the xml file makes the tool to ignore all the lines which are having only the word " case : ". For example all below lines will get ignored.
case 1:
case 2:
case ABC:
now, i want the same code for ignoring the any line which starts with " : " (colon). Example,
:END ---> this line should be ignored
:STOP ---> this line should be ignored
| [reply] |
If you want three separate regexes, just split the combined one at the | symbol:- /^\s*case [^:]*:/ (I have amended this to conform to your examples)
- /^:/
- /^struct/
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James My blog: Imperial Deltronics
| [reply] [d/l] [select] |
| [reply] [d/l] |