LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Translation of a dynamic regex in awk (https://www.linuxquestions.org/questions/linux-newbie-8/translation-of-a-dynamic-regex-in-awk-4175722797/)

Faki 03-07-2023 09:46 AM

Translation of a dynamic regex in awk
 
I am writing a number of dynamic regular expressions. These can get quite complicated.

Is it possible to write an awk function that takes a dynamic regex and prints only what
awk would actually see when interpreting the dynamic regex ?

pan64 03-07-2023 10:02 AM

regexp itself is just a string. You can print it as any other string (if it is stored in a variable). But you cannot print a regex like this:
Code:

gsub(/regex/, "")
because it is not stored anywhere.

Faki 03-07-2023 11:37 AM

You are correct, I can print the string. But the string could contain any sort of escape sequences and so on.

What I am looking to do is exclude the complications to have a better and clear idea of what it would match.

pan64 03-08-2023 12:19 AM

www.regex101.com


All times are GMT -5. The time now is 12:34 PM.