I want to use regex to highlight the functions of a new programming language but i have a problem in EXCLUDING the functions that have the word "exported" so
ok lines that I have to match examples:
routine hello
ROUTINE hello
   routine hello
   ROUTINE hello(a:INTEGER)
   routine hello (a   :  INTEGER)
   routine hello (a   :  INTEGER , b: STRING)
lines that I don't want to match examples:
   routine hello (a   :  INTEGER , b: STRING) exported
I've tried with
^[[:blank:]]*routine[[:blank:]]+([[:alnum:]_])+[[:blank:]]*([[:alnum:]_:,[:space:]]*)/^(?!.*exported)$/
but it doesn't work.
The most portable regex would be ^[ \t\n]*$ to match an empty string (note that you would need to replace \t and \n with tab and newline accordingly) and [^ \n\t] to match a non-whitespace string. Save this answer.
$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.
If you are having a string with special characters and want's to remove/replace them then you can use regex for that. Use this code: Regex. Replace(your String, @"[^0-9a-zA-Z]+", "")
Wildcard which matches any character, except newline (\n). | Matches a specific character or group of characters on either side (e.g. a|b corresponds to a or b) \ Used to escape a special character.
You can use an expression like this to match all lines that don't contain the word "exported":
(?m)^(?!.*\bexported\b).*$
                        The following expression also does the trick:
^(?!.*exported).*$
|________________   line begin 
 |_______________   negative lookahead
    |____________   any characters
      |__________   your exclusion word
               |_   any characters
                 |_ end of line
                        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