php - Filter a version number out of a string -


i want filter number out of string php preg_match (they versions of software):

  • 1.6.2
  • 1.6.2#2
  • 1.7

(1.6.2#2 2. beta of 1.6.2)

so when there string like:

lorem ipsum dolor sit amet, consetetur sadipscing elitr, 1.6.2# sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

now want string contains "1.6.2#2"

i tried (\d?[.|#]?)* not work

use regular expression

/(\d+\.\d+(\.\d+)?(#\d+)?)/ 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -