-1

So string looks like that:

 abc_#xoxo#_xyz

I want to pull out everyting except _#*#_ and get them in two match results (abc and xyz). I made a regexp to get stuff from inside:

 (?<=_#)[^}]*(?=#_)

I have struggled with it for quite a while and have no idea how to catch that, suggestions?

steenslag
  • 79,051
  • 16
  • 138
  • 171

1 Answers1

1

If I understood your problem correctly, this is a very easy task.

(.*)_#.*#_(.*)

Link: http://rubular.com/r/iymHrETOlU

Here's some ruby code

s = 'abc_#xoxo#_xyz'
regex = /(.*)_#.*#_(.*)/

match = regex.match(s)
match[1] # => "abc"
match[2] # => "xyz"
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367