The following regular expression is written in the Python dialect:
^( )*#(\s+\S(.*\S)?)?$
Can anyone see a better way to wright this? For those not sure what it is saying:
Can it be simplified anymore than this?
^( )*#(\s.*\S)?$
One way to re-write the regexp to enhance readability (to reduce the chance to count consecutive whitespaces):
^( {4})*#(\s.*\S)?$
In the words of @Noctis, it shortens the compiler debug output.
Procedure to get (\s.*\S)? from (\s+\S(.*\S)?)?
\s+ => \s(\s)*
\S(.*\S)? => \S or \S.*\S => (\S.*)?\S
(\s+\S(.*\S)?)? => (\s(\s)*(\S.*)?\S)? => (\s.*\S)? because (\s)*(\S.*)? => .*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With