[Regex] How to get numbers without a letter before
source link: https://www.codesd.com/item/regex-how-to-get-numbers-without-a-letter-before.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Regex] How to get numbers without a letter before
at first I've only discover Regex few days ago...
And I am trying to use Regex to get digits/numbers but only if there is no letters. And even if the letters are before '('
Ex:
- A = 3.2 => 3.2
- AVariable5 = 3.0 => 3.0
- vec(0,255)) => 0 & 255
- vec2(0,0) => 0 & 0
Currently I am using the expression [\d.]+ to get digits with the '.'
I've tried few things, but no results, always getting more things or nothing.
So I'm asking to you how to do it and with explication if possible.
Thanks to you.
(Sorry if my english is bad)
\d+
is part of the story; what you need is a condition on the prefix, a look-behind, to require that the character before the match is not a letter:
\b(?<![A-Za-z])\d+([.]\d+)?
Related Articles
How to get numbers of this type of string in C
How to get information without using pyCURL (requests)
How to get content without nested elements with Nokogiri
How to get a date six months before the current date in a single line in Java?
How to get all the main characters before the first instance of a number
Regex: How to get the file name without the first numbers?
Regex how to get a full match of the nth word (without using groups that are not captured)
perl regex: how to get open-reading-frames without stopping-internal codons?
PHP Regex - How to Get Multiple Words Between Analyzed Content
HTML DOM: How to get items without losing kids?
Regex how to get the data out of json
Java regex - How to get spaces and characters?
How to get numbers with a prefix?
how to get numbers of a string in javascript?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK