tags:

views:

45

answers:

4

(any symbol) _ (any symbol) _ (any symbol)

need as much as possible short regex patterns to extract symbols sequence between _, for ex:

abc123_abc12345ABC_123abc regex should extract - abc12345ABC

+3  A: 

This would do it:

^[^_]+_([^_]+)_[^_]+$

The middle capture group would grab the middle string of characters.

Andrew Hare
A: 

([^_]*)_([^_]*)_([^_]*)

James Keesey
A: 

How about

^.*?_(.*?)_.*$
codaddict
A: 

With (any symbol) do you really mean any symbol? Can it contain newlines? Can it contain underscores?

For now, I'll give this short regex:

_(.+)_
Geert