Skip to content
Advertisement

capture the starting characters with many patterns

I need to capture the starting characters from database objects with various pattern search.

I have tried using the REGEX expression ,below query i am trying and the expected data set to be.

Query 1

Expected Data Set

Unfortunately i was not able to separate the below

#Tableau_6_sid:15251a_4i_2a –> #Tableau

/15722c29d_PhotoImageCameraPro –> /15722c29d

JAVA/15722c29d_PhotoImageqeeee –> JAVA

how to resolve ?

so how to capture the last character after _ , below is an example

Query 2 – capture the last characters

Expected Data Set

Unfortunately i was not able to separate the below

Teradata/jdbc/EXAcore/MPPReader –> MPPReader

sqlj/modegen/engine/FuncInit –> FuncInit

moon/aio/af/ext/ISCII11$Decoder –> ISCII11$Decoder

Advertisement

Answer

For the regex, you could add matching / and # in the character class followed by matching as least as possible chars until the next / or _ using another character class.

If the pattern is not case insensitive, you could also add a-z

Regex demo

If the / and # can only be at the start, you might also optionally match either one of them:

See another regex demo

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement