in reply to Re: Regular Expression
in thread Regular Expression
Moreover, if there were zero-digits after the equals symbol, the data would not match OP's explicit example and implicit spec.
Update re ckj's update which is MOSTLY WRONG. Reread the above.
(\d+) captures one or more digits. (\d*) matches ZERO digits which is useless.
perl -e "use 5.014; my $foo= 'bc'; if ($foo = /(\d*)/ ) {say 'match'; +}else{ say 'Duh!';}" match
OP does not ask to capture the spaces. There is no need to capture the spaces to account for their quantity; 0, 1, 2 or whatever.
Your parens are capturing. Grouping (aka 'non-capturing') parens are (?:...).
Please read carefully before unburdening yourself of mis-statements.
Despite it's irrelevance here, though, you did get one aspect of your reply partially right: "TIMTOWTDI." But -- as the rest of that wisdom goes - 'and most of them are wrong.'
</Update>
|
|---|