John W. Krahn wrote:
> Steve Bertrand wrote:
>> Hi everybody,
>
> Hello,
>
>> I am far from a regex guru, so I know that I can get advice on how to
>> learn to improve my regex knowledge so I can better my currently working
>> code to protect against failure in the future. I would appreciate so
What I mean is, if you were to use a regex as opposed to using
split(), how would you have written:
if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
...to do the task I originally requested help with?
Aside from removing .* at the beginning and removing '|' from the
Steve Bertrand wrote:
The \w character class matches any "word" character where "word" is
defined as any alphabetic character or any numerical digit or the '_'
character. The '|' which is used for alternation outside of a
character class just matches a literal '|' character inside a
character
The \w character class matches any "word" character where "word" is
defined as any alphabetic character or any numerical digit or the '_'
character. The '|' which is used for alternation outside of a character
class just matches a literal '|' character inside a character class. The
\s characte
Steve Bertrand wrote:
if
(/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
The .* pattern at the beginning is useless as it causes unnecessary
back-tracking, just remove it.
Ok.
The character class [\w|\s] includes both the '|' and '_' characters
but it doesn't appea
if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
The .* pattern at the beginning is useless as it causes unnecessary
back-tracking, just remove it.
Ok.
The character class [\w|\s] includes
both the '|' and '_' characters but it doesn't appear that that field
woul
Gunnar Hjalmarsson wrote:
if
(/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
-^^
This captures the "result", but with a trailing space. You may want
to let the capturing parentheses be followed by \s to prevent that.
With "captures the r
Steve Bertrand wrote:
Hi everybody,
Hello,
I am far from a regex guru, so I know that I can get advice on how to
learn to improve my regex knowledge so I can better my currently working
code to protect against failure in the future. I would appreciate some
criticism, with explanations as to
[ Please don't remove attributions. ]
Steve Bertrand wrote:
Gunnar Hjalmarsson wrote:
Steve Bertrand wrote:
if
(/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
-^^
This captures the "result", but with a trailing space. You may want to
let
if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
-^^
This captures the "result", but with a trailing space. You may want to
let the capturing parentheses be followed by \s to prevent that.
$result = $1 if $1;
Steve Bertrand wrote:
if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
-^^
This captures the "result", but with a trailing space. You may want to
let the capturing parentheses be followed by \s to prevent that.
$result
Hi everybody,
I am far from a regex guru, so I know that I can get advice on how to
learn to improve my regex knowledge so I can better my currently working
code to protect against failure in the future. I would appreciate some
criticism, with explanations as to the changes if possible.
I've
12 matches
Mail list logo