in reply to Split string in groups with non white space using regex
#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1206677 use strict; use warnings; for ( 'Thanos1983+|Thanos1983', 'Thanos1983+|' ) { print; /([^|]*)(\|)([^|]*)/ and print "I found:\t\$1: '$1'\t\$2: '$2'\t\$3: + '$3'"; }
Outputs:
Thanos1983+|Thanos1983 I found: $1: 'Thanos1983+' $2: '|' $3: 'Thanos1983' Thanos1983+| I found: $1: 'Thanos1983+' $2: '|' $3: ''
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split string in groups with non white space using regex
by thanos1983 (Parson) on Jan 04, 2018 at 11:53 UTC | |
by AnomalousMonk (Archbishop) on Jan 04, 2018 at 18:12 UTC | |
by thanos1983 (Parson) on Jan 05, 2018 at 12:39 UTC | |
by AnomalousMonk (Archbishop) on Jan 05, 2018 at 14:14 UTC |