Need a Regular expression to extract 5th to 8th characters in a string
Need a UNIX Regular expression to extract letters from 4th to 8th.
For example: File 15870712.iis If we want to extract Ist 3 digits we can give '开发者_如何学编程^([0-9][0-9][0-9])' > 158
I need the 5th 6th 7th and 8th chara. > 0712
$letters = substr($string, 4, 4);
Its not using regular expressions, but does exactly, what you want. According your question there is absolutely no need for complex pattern matching.
Letters or any character? If the latter:
/^....(....)/
This will match digits from position 5 through 8, and assumme any character on the first 4 positions.
^.{4}([0-9]{4})
If you need the first 4 positions to be digits as well you can use this instead:
^[0-9]{4}([0-9]{4})
精彩评论