-1

I am working with regular expression with the module re in python. I am supose to match everything before a slash, put the match in a variable, and match everything after a slash, and put it in another variable.

For example:

for the string

"NlaIII/Csp6I"

I would like to match NlaIII and store it in a variable and match Csp6I and store it in another variable

variable_1 = "NlaIII"
variable_2 = "Csp6I"

Using python module re, I have been able to match everything before the slash with the following regular expression:

first_enzyme = re.compile('.+?(?=\W+)')

But I am completely unable to everything after a backslash without the backslash

Thank you very much for your help!

Praderas
  • 471
  • 4
  • 14

1 Answers1

1

You don't need a regex for that at all.

s = "NlaIII/Csp6I"
variable_1, variable_2 = s.split('/')
TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97