in reply to Re^5: Regex help
in thread Regex help
Oh, I was vaguely aware of it. But I didn't realize that that was the exact point japhy addressed!
@rt = ( q/\b/, # standard word boundary q/(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))/, # [japhy]-explicit-left q/(?:(?<=\w)(?!\w)|(?<=\W)(?!\W))/, # [japhy]-explicit-right q/(?(?=\w)(?<!\w)|(?<!\W))/, # [japhy]-conditional-left q/(?(?<=\w)(?!\w)|(?!\W))/, # [japhy]-conditional-right q/(?:(?=\w)(?<!\w)|(?!\w)(?<=\w))/, # [ysth]-\b-emulation ); for my $text ('this,', ',that') { for my $rxstr (@rt) { my $try = $rxstr . (' ' x (31 - length $rxstr)); my $rx = qr/$rxstr/; (my $txt = $text) =~ s/$rx/*/g; print "[$try]$txt\n"; } }
[\b ]*this*, [(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))]*this*, [(?:(?<=\w)(?!\w)|(?<=\W)(?!\W))]this*,* [(?(?=\w)(?<!\w)|(?<!\W)) ]*this*, [(?(?<=\w)(?!\w)|(?!\W)) ]*this*,* [(?:(?=\w)(?<!\w)|(?!\w)(?<=\w))]*this*, [\b ],*that* [(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))]*,*that [(?:(?<=\w)(?!\w)|(?<=\W)(?!\W))],*that* [(?(?=\w)(?<!\w)|(?<!\W)) ]*,*that* [(?(?<=\w)(?!\w)|(?!\W)) ],*that* [(?:(?=\w)(?<!\w)|(?!\w)(?<=\w))],*that*
|
|---|