Regex, take last match before suffix [duplicate]
up vote
1
down vote
favorite
This question already has an answer here:
Tempered Greedy Token - What is different about placing the dot before the negative lookahead
3 answers
I know this is going to sound like the kind of question that's been asked hundreds of times. But I've been searching for over an hour and none of the solution I found worked in my case.
I have many different numbers of the form
d*'?d+.dd
An example of string I work with would be
The base item costs 1'245.48, the tax is of 18.45 and the bonus of 250.00, the total price is of 1'013.93. In case of trouble, contact our e-mail. Bank account 784.45
I want to get ONLY the last match corresponding to my regex before e-mail
, i.e 1'013.93
. I would like to use only regex, no extra python, javascript or anything
I have tried code inspired by this Regex Last occurrence?, this How to capture only last match in Regex, this Find Last Occurrence of Regex Word, and many other expressions of my own, but so far there always seems to be one piece missing
For example, after successfully selecting the very last number with (d*'?d+.dd)(?!.*d*'?d+.dd)
, I tried (d*'?d+.dd)(?!.*d*'?d+.dd)(?=e-mail)
, which does not match anything.
Any insights?
regex
marked as duplicate by Sebastian Proske, Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 20:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
This question already has an answer here:
Tempered Greedy Token - What is different about placing the dot before the negative lookahead
3 answers
I know this is going to sound like the kind of question that's been asked hundreds of times. But I've been searching for over an hour and none of the solution I found worked in my case.
I have many different numbers of the form
d*'?d+.dd
An example of string I work with would be
The base item costs 1'245.48, the tax is of 18.45 and the bonus of 250.00, the total price is of 1'013.93. In case of trouble, contact our e-mail. Bank account 784.45
I want to get ONLY the last match corresponding to my regex before e-mail
, i.e 1'013.93
. I would like to use only regex, no extra python, javascript or anything
I have tried code inspired by this Regex Last occurrence?, this How to capture only last match in Regex, this Find Last Occurrence of Regex Word, and many other expressions of my own, but so far there always seems to be one piece missing
For example, after successfully selecting the very last number with (d*'?d+.dd)(?!.*d*'?d+.dd)
, I tried (d*'?d+.dd)(?!.*d*'?d+.dd)(?=e-mail)
, which does not match anything.
Any insights?
regex
marked as duplicate by Sebastian Proske, Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 20:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
In your case that would be(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
Tempered Greedy Token - What is different about placing the dot before the negative lookahead
3 answers
I know this is going to sound like the kind of question that's been asked hundreds of times. But I've been searching for over an hour and none of the solution I found worked in my case.
I have many different numbers of the form
d*'?d+.dd
An example of string I work with would be
The base item costs 1'245.48, the tax is of 18.45 and the bonus of 250.00, the total price is of 1'013.93. In case of trouble, contact our e-mail. Bank account 784.45
I want to get ONLY the last match corresponding to my regex before e-mail
, i.e 1'013.93
. I would like to use only regex, no extra python, javascript or anything
I have tried code inspired by this Regex Last occurrence?, this How to capture only last match in Regex, this Find Last Occurrence of Regex Word, and many other expressions of my own, but so far there always seems to be one piece missing
For example, after successfully selecting the very last number with (d*'?d+.dd)(?!.*d*'?d+.dd)
, I tried (d*'?d+.dd)(?!.*d*'?d+.dd)(?=e-mail)
, which does not match anything.
Any insights?
regex
This question already has an answer here:
Tempered Greedy Token - What is different about placing the dot before the negative lookahead
3 answers
I know this is going to sound like the kind of question that's been asked hundreds of times. But I've been searching for over an hour and none of the solution I found worked in my case.
I have many different numbers of the form
d*'?d+.dd
An example of string I work with would be
The base item costs 1'245.48, the tax is of 18.45 and the bonus of 250.00, the total price is of 1'013.93. In case of trouble, contact our e-mail. Bank account 784.45
I want to get ONLY the last match corresponding to my regex before e-mail
, i.e 1'013.93
. I would like to use only regex, no extra python, javascript or anything
I have tried code inspired by this Regex Last occurrence?, this How to capture only last match in Regex, this Find Last Occurrence of Regex Word, and many other expressions of my own, but so far there always seems to be one piece missing
For example, after successfully selecting the very last number with (d*'?d+.dd)(?!.*d*'?d+.dd)
, I tried (d*'?d+.dd)(?!.*d*'?d+.dd)(?=e-mail)
, which does not match anything.
Any insights?
This question already has an answer here:
Tempered Greedy Token - What is different about placing the dot before the negative lookahead
3 answers
regex
regex
edited Nov 9 at 16:56
HugoTeixeira
2,4052921
2,4052921
asked Nov 9 at 16:37
Skum
18210
18210
marked as duplicate by Sebastian Proske, Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 20:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sebastian Proske, Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 20:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
In your case that would be(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52
add a comment |
2
In your case that would be(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52
2
2
In your case that would be
(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52
In your case that would be
(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You could try this:
((d+')?d+(.d+)?)(?=[^d]+e-mail)
The first group matches the number you want. From regex101.com:
add a comment |
up vote
1
down vote
Something like this with an extra number format check:
((d{1,3}')*(d{1,3}).d{2})(?=D+e-mail)
Demo
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You could try this:
((d+')?d+(.d+)?)(?=[^d]+e-mail)
The first group matches the number you want. From regex101.com:
add a comment |
up vote
1
down vote
accepted
You could try this:
((d+')?d+(.d+)?)(?=[^d]+e-mail)
The first group matches the number you want. From regex101.com:
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You could try this:
((d+')?d+(.d+)?)(?=[^d]+e-mail)
The first group matches the number you want. From regex101.com:
You could try this:
((d+')?d+(.d+)?)(?=[^d]+e-mail)
The first group matches the number you want. From regex101.com:
answered Nov 9 at 16:55
HugoTeixeira
2,4052921
2,4052921
add a comment |
add a comment |
up vote
1
down vote
Something like this with an extra number format check:
((d{1,3}')*(d{1,3}).d{2})(?=D+e-mail)
Demo
add a comment |
up vote
1
down vote
Something like this with an extra number format check:
((d{1,3}')*(d{1,3}).d{2})(?=D+e-mail)
Demo
add a comment |
up vote
1
down vote
up vote
1
down vote
Something like this with an extra number format check:
((d{1,3}')*(d{1,3}).d{2})(?=D+e-mail)
Demo
Something like this with an extra number format check:
((d{1,3}')*(d{1,3}).d{2})(?=D+e-mail)
Demo
edited Nov 9 at 17:27
answered Nov 9 at 17:08
wp78de
9,78951738
9,78951738
add a comment |
add a comment |
2
In your case that would be
(d*'?d+.dd)(?:(?!d+.dd).)*e-mail
– Sebastian Proske
Nov 9 at 16:52