regex for regex result or twice regex - regex

i want to select all money numbers (red) and this is regex which doesn't work
I can improve regex so that it'll select all numbers ranges like this
May I use some post select regex to remove all dates/time from it?
like where it
doesn't contain '/'
and double '.'
and ':'

You may use
\b(?<!\d[:\/.])\d+(?:,\d+)*(?:\.\d+)?(?![.\/:]?\d)
See the regex demo
Regex details
\b - a word boundary
(?<!\d[:\/.]) - no digit + :, / or . allowed immediately to the left of the current location
\d+ - 1+ digits
(?:,\d+)* - zero or more occurrences of , and 1+ digits
(?:\.\d+)? - an optional occurrence of . and 1+ digits
(?![.\/:]?\d) - no optional ., / or : followed with a digit are allowed immediately to the right of the current location.

Related

Regex of dynamic block of characters

I have a block of number characters separated by '=' and the number range can be always different on both sides.
Example: 12345678999999=654784651321, next time it could be: 4567894135=456789211
I need help with finding suitable regex which select me always numbers between first 6 and last 4 digits of left side of block and then all numbers after 7th digit of right side of block:
123456[][][][]9999=6547846[][][][][]
Is this somehow possible?
[0-9]{6}([0-9]*)[0-9]{4}=[0-9]{7}([0-9]*)
Assuming the difficulty isn't matching a continuous set of digits, but rather matches each digit seperately try:
(?:^\d{6}|=\d{7}|\G)(?=\d{5,8}=|\d*$)\K\d
See an online demo
(?: - Open non-capture group for alternation;
^\d{6} - Match start-line anchor followed by 6 digits;
| - Or;
=\d{7} - Match a literal '=' followed by exactly 7 digits;
| - Or;
\G - Assert position at end of previous match or start of string;
(?=\d{5,8}=|\d*$) - Positive lookahead to assert possition is followed by either 5-8 digits upto an '=' or 0+ (greedy) digits upto end-line anchor;
\K - Reset starting point of previous reported match;
\d - A single digit.
Alternatively, if you have an environment that supports zero-width lookbehind like JavaScript or PyPi's regex package in Python, try:
(?:(?=\d{5,8}=)(?<=\d{6})|(?<==\d{7,}))\d
See an online demo
(?: - Open non-capture group for alternation;
(?=\d{5,8}=)(?<=\d{6}) - Positive lookahead to assert position is followed by 5-8 digits and an '=' but also preceded by at least 6 digits;
| - Or;
(?<==\d{7,}) - Positive lookbehind to assert position is preceded by an '=' followed by 7+ digits;
\d - A single digit.
// 6 NOT number or =
// ||
// \/
/[0-9]{6}[^\=0-9]*\=[^\=0-9]*[0-9]{4}/

Regex exclude whitespaces from a group to select only a number

I need to take only a number (a float number) from a text, but I can't remove the whitespaces...
** Update
I have a problem with this method, I only need to consider numbers and ',' between '- EUR' and 'Fee' as rule.
You can use
- EUR\W*(.*?)\W*Fee
See the regex demo.
Variations of the regex that might work in different regex engines:
- EUR\W*\K.*?(?=\W*Fee)
(?<=- EUR\W*).*?(?=\W*Fee)
Details:
- EUR - literal text
\W* - zero or more non-word chars
(.*?) - Group 1: any zero or more chars other than line break chars as few as possible
\W*- zero or more non-word chars
Fee - a string.
You could also match the number format in capture group 1
- EUR\b\D*(\d+(?:,\d+)?)\s+Fee\b
- EUR\b Match - EUR and a word boundary
\D* Match 0+ times any char except a digit
( Capture group 1
\d+(?:,\d+)? Match 1+ digits with an optional decimal part
) Close group 1
\s+Fee\b Match 1+ whitespace chars, Fee and a word boundary
Regex demo
this is working i removed the , from (.) in test string.
Regex example - working

Extracting a number in string inside brackets with Regexextract

I am trying to extract number only (float?) from accounting numbers in google sheet with abbrev. units like K,M,B and sometimes in a bracket when negative. Sorry I am so new in regex, how to write a regular express covering different possibilities like (213M),(31.23B)?
\(([0-9.]+\.\[0-9.]+)\)
You may use
\((-?\d+(?:\.\d+)?)[KMB]\)
Details
\( - a literal ( char
(-?\d+(?:\.\d+)?) - Group 1:
-? - an optional -
\d+ - 1+ digits
(?:\.\d+)? - an optional non-capturing group matching one or zero occurrences of a dot followed with 1+ digits
[KMB] - a character class matching K, M or B
\) - a literal ) char.
See the regex demo.

How do you complete the following Regex

I am looking for a regex expression that will accept the following: The capital letter A followed by any number of digits. This might also be a decimal number. All of these are valid: A1, A500, A543.987
This is NOT OK to accept: Apple, AE100
Currently I have [A]\w.[0-9]* but it accepts App and AE100.
You may use the following regex if the entire string should match:
^A[0-9]+(?:\.[0-9]+)?$
Or, to match these strings as whole words:
\bA[0-9]+(?:\.[0-9]+)?\b
See the regex demo.
Details
^ - start of string / \b - a word boundary
A - an A
[0-9]+ - 1+ digits
(?:\.[0-9]+)? - an optional sequence of . and then 1+ digits
$ - end of string / \b - a word boundary.
I would suggest "A\d+(\.\d+)?". \d represents all digits, the + is one or more characters and the (\.\d+)? is a . followed by one or more digits. But the ? specifies it's optional.

Regex Match for Valid Dates only

I am trying to create a regex that only matches for valid dates (in MM/DD or MM/DD/YY(YY) format)
My current regex (\d+)/(\d+)/?(\d+)? is very simple but it matches any number that has a / before/after. I.e. if a string is 2015/2016 12/25 it will see both of these as matches but i only want the 12/25 portion.
Here is a link to some sample RegEx.
You can add word boundaries (\b) to make sure you match the date string as a whole "word" (so that the match does not start in the middle of a number) and restrict the occurrences \d matches with the help of limiting quantifiers:
\b(\d{2})/(\d{1,2})/?(\d{4}|\d{2})?\b
See the regex demo
The regex breakdown:
\b - word boundary to make sure there is a non-word character or start of string right before the digit
(\d{2}) - match exactly 2 digits
/ - match a literal /
(\d{1,2}) - match and capture 1 to 2 digits
/? - match 1 or 0 /
(\d{4}|\d{2})? - match 1 or 0 occurrences of either 4 or 2 digits
\b - trailing word boundary