Wikipedia:Reference desk/Archives/Computing/2017 September 26
Computing desk | ||
---|---|---|
< September 25 | << Aug | September | Oct >> | September 27 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
September 26[edit]
Regex: How to delete all comments and all that comes after them in a row?[edit]
I tried this:
?^# *
To delete all commets starting with #space (and that might be preceded by a space).
It does delete them, but not everything coming after them in the same row. Ben-Yeudith (talk) 06:34, 26 September 2017 (UTC)
- Try "^ ?# .*" based on your description, if a comment is always on its own line. The last two characters (.*) means 'everything'. -- zzuuzz (talk) 07:11, 26 September 2017 (UTC)
- Hmm, sadly this seems to delete everything in the file, not only comments. Ben-Yeudith (talk) 07:19, 26 September 2017 (UTC)
- Depending on how you open the file, ".*" will usually match newline characters as well.
^ ?# [^\n]*
could work (I have not tested it) ([^\n] means "any non-newline character"). TigraanClick here to contact me 11:05, 26 September 2017 (UTC)
- Depending on how you open the file, ".*" will usually match newline characters as well.
- Hmm, sadly this seems to delete everything in the file, not only comments. Ben-Yeudith (talk) 07:19, 26 September 2017 (UTC)
- If you want to express " lines that begins with # or with space and #" that won't be
?^
- This
^
- matches the beginning, there's nothing before the beginning, optional or not. Make the space optional.B8-tome (talk) 12:20, 26 September 2017 (UTC)
- The following worked. Thanks.
# [^\n]*
Ben-Yeudith (talk) 13:27, 26 September 2017 (UTC)