(\S+)\.|
will match and capture any number (one or more) of non-space characters, followed by a dot character.
(\S+) |
will match and capture any number (one or more) of non-space characters, followed by a space character (assuming the regular expression isn’t modified with a /x
flag).
In both cases, these constructs appear to be one component of an alternation.
Breaking it down:
(
….)
: Group and capture.\S
: Non-space character.+
: One or more.\.
: A dot character (without the backslash escape, the
dot has special meaning).: Just an ordinary single space.
|
: Alternation (similar to logical or).
See perlretut for a crash course in Perl’s regular expressions. Also perlintro is a good starting point for learning Perl, and perlre is the canonical explanation of Perl’s regular expressions. There are many other useful documents in Perl’s documentation, but these would get you moving in the right direction.
If you want to learn everything there was to know in 2005 about common regular expression flavors, Mastering Regular Expressions, 3rd Edition is unparalleled. And despite being a few years old, it’s still one of the best resources anywhere on regular expressions.
solved Difference between “(\S+)\.|” and “(\S+) |” in Perl [duplicate]