简体   繁体   中英

PHP preg pattern needed

0 10 2 012 11 12 12 test -f 13 x   xx
0 2   102 012 12 12 test -f 11 xxddd 22x
0 102 01 2  1    12   12 test -f 12 xxx

I need to find the number (between 1 and 5 digits) following the -f parameter using preg_match() .

I'm a total bumpkin regarding PCRE matches.

I played arround with online preg testers and get stuck with \\(.*)-f(\\d{1,5})(.*)$\\

Oh I didnt notice how close I got it:

\^.* -f (\d{1,4}).*$\

Array
(
    [0] =>     0 10 2 012 11 12 12 test -f 13 x   xx
    [1] => 13
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM