B
B
becks2013-02-18 11:11:02
Regular Expressions
becks, 2013-02-18 11:11:02

Prompt with regular expression

Can you please tell me how the regular expression will look like for extracting values ​​from a string, separated by a semicolon with any number of spaces:

somestuff1;somestuff2; somestuff3; .... ; somestuffN

somestuff can contain any characters except a semicolon.

It is the usual regular expression (the use of metacharacters) that is of interest, and not the implementation in PHP-Shevsky or any other dialect.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
S
stan_jeremy, 2013-02-18
@becks

well, in all languages ​​with perl-like regular expressions there is a regular expression split, although here it will also be superfluous (preg_split, split, etc.). Or are you looking for a very sophisticated option?

S
Sergey Belov, 2013-02-18
@BeLove

Decision

T
theli, 2013-02-18
@theli

(?:\ +)?([^;]*[^\ ;])(?:\ *)?
but still the split + trim option or analogues would be better.

W
WEBIVAN, 2013-02-18
@WEBIVAN

So

S
Stronix, 2013-02-18
@Stronix

(.+?)(?:\;|\Z)

T
theli, 2013-02-18
@theli

well, I meant split from python (because I'm not familiar with php), which apparently is an analogue of your explode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question