-1

I am attempting to use Regex to bookmark all lines that contains non-alphabetical or non-numerical characters after a "\" is located in the line.

For example if I had a text file with the following lines I want to bookmark the middle line

Hello! This\Is a test
Hello! This\Is a test!
Hello! This\Is another test

The middle line contains ! after the \ so it would be bookmarked.

Michał Turczyn
  • 28,428
  • 14
  • 36
  • 58
  • 1
    Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/a/2759417/3832970) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Sep 17 '19 at 06:54

3 Answers3

0

You may try the following regex search pattern:

^.*\\.*[^A-Za-z0-9 ].*$

This would match any offending lines as you have described.

Tim Biegeleisen
  • 387,723
  • 20
  • 200
  • 263
0

Try (?=.+\\[0-9a-zA-Z ]+[^\n0-9a-zA-Z ]).+

Explanation:

(?=...) - positive lookahead - assert what follows matches pattern

.+ - match one or more of any characters

\\ - amtch \ literally

[0-9a-zA-Z ]+ - match one or more letters, digits or space

[^\n0-9a-zA-Z ] - match character other from letter, digit, space or newline

Demo

Michał Turczyn
  • 28,428
  • 14
  • 36
  • 58
0
  • Ctrl+F
  • Select "Mark" tab
  • Find what: \\.*[^\r\n0-9a-zA-Z ]
  • check Wrap around
  • check Regular expression
  • UNCHECK . matches newline
  • Check Bookmark line
  • Mark all

Explanation:

\\                  # a backslash
.*                  # 0 or more any character but newline
[^\r\n0-9a-zA-Z ]   # a character that is NOT linebreak, alphanumeric, space

Screen capture:

enter image description here

Toto
  • 83,193
  • 59
  • 77
  • 109