regex match number in parentheses (Firefox) [duplicate]










-1
















This question already has an answer here:



  • Javascript regex negative lookbehind not working in firefox

    3 answers



I have string like this:



(3) Request Inbox


Now I want to detect number 3 in parentheses. Pay attention just 3. I write this regex in javascript but it doesn't work in Firefox.



var regex = new RegExp(/(?<=()d+(?:.d+)?(?=))/g);



Error in console: SyntaxError: invalid regexp group




Demo link










share|improve this question















marked as duplicate by Mohammad, Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 15 '18 at 7:40


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.


















  • If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

    – fubar
    Nov 15 '18 at 6:22
















-1
















This question already has an answer here:



  • Javascript regex negative lookbehind not working in firefox

    3 answers



I have string like this:



(3) Request Inbox


Now I want to detect number 3 in parentheses. Pay attention just 3. I write this regex in javascript but it doesn't work in Firefox.



var regex = new RegExp(/(?<=()d+(?:.d+)?(?=))/g);



Error in console: SyntaxError: invalid regexp group




Demo link










share|improve this question















marked as duplicate by Mohammad, Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 15 '18 at 7:40


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.


















  • If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

    – fubar
    Nov 15 '18 at 6:22














-1












-1








-1









This question already has an answer here:



  • Javascript regex negative lookbehind not working in firefox

    3 answers



I have string like this:



(3) Request Inbox


Now I want to detect number 3 in parentheses. Pay attention just 3. I write this regex in javascript but it doesn't work in Firefox.



var regex = new RegExp(/(?<=()d+(?:.d+)?(?=))/g);



Error in console: SyntaxError: invalid regexp group




Demo link










share|improve this question

















This question already has an answer here:



  • Javascript regex negative lookbehind not working in firefox

    3 answers



I have string like this:



(3) Request Inbox


Now I want to detect number 3 in parentheses. Pay attention just 3. I write this regex in javascript but it doesn't work in Firefox.



var regex = new RegExp(/(?<=()d+(?:.d+)?(?=))/g);



Error in console: SyntaxError: invalid regexp group




Demo link





This question already has an answer here:



  • Javascript regex negative lookbehind not working in firefox

    3 answers







javascript regex string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 6:10







Ehsan Ali

















asked Nov 15 '18 at 5:54









Ehsan AliEhsan Ali

47511032




47511032




marked as duplicate by Mohammad, Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 15 '18 at 7:40


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 Mohammad, Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 15 '18 at 7:40


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.














  • If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

    – fubar
    Nov 15 '18 at 6:22


















  • If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

    – fubar
    Nov 15 '18 at 6:22

















If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

– fubar
Nov 15 '18 at 6:22






If you just want to match the number, do you even need the lookahead? What about something as simple as: /^((d+))/g - it matches in group 1. Or do you mean, only the full match?

– fubar
Nov 15 '18 at 6:22













2 Answers
2






active

oldest

votes


















0














For a full match try this:



var regex = new RegExp(/(?=d+))d+/g);





share|improve this answer























  • Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

    – Foo
    Nov 15 '18 at 6:30


















2














Positive lookbehind is not supported by most browsers so use an alternative way to get your answer.



Something like this,



var string = "somestring(12)";
var exp = /(?:()(d+)(?:.d+)?(?=))/;
var mat = string.match(exp);

if(mat)
console.log(mat[1]);// second index



This should only give 12 as the answer






share|improve this answer

























  • it has problem, please check it https://regex101.com/r/eNOcvx/2

    – Ehsan Ali
    Nov 15 '18 at 8:12







  • 1





    The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

    – Simba3696
    Nov 15 '18 at 8:19

















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














For a full match try this:



var regex = new RegExp(/(?=d+))d+/g);





share|improve this answer























  • Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

    – Foo
    Nov 15 '18 at 6:30















0














For a full match try this:



var regex = new RegExp(/(?=d+))d+/g);





share|improve this answer























  • Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

    – Foo
    Nov 15 '18 at 6:30













0












0








0







For a full match try this:



var regex = new RegExp(/(?=d+))d+/g);





share|improve this answer













For a full match try this:



var regex = new RegExp(/(?=d+))d+/g);






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 6:27









Andrey StarkovAndrey Starkov

894




894












  • Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

    – Foo
    Nov 15 '18 at 6:30

















  • Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

    – Foo
    Nov 15 '18 at 6:30
















Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

– Foo
Nov 15 '18 at 6:30





Welcome to StackOverflow! Your answer need more explanation about how the code works to be a good answer.

– Foo
Nov 15 '18 at 6:30













2














Positive lookbehind is not supported by most browsers so use an alternative way to get your answer.



Something like this,



var string = "somestring(12)";
var exp = /(?:()(d+)(?:.d+)?(?=))/;
var mat = string.match(exp);

if(mat)
console.log(mat[1]);// second index



This should only give 12 as the answer






share|improve this answer

























  • it has problem, please check it https://regex101.com/r/eNOcvx/2

    – Ehsan Ali
    Nov 15 '18 at 8:12







  • 1





    The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

    – Simba3696
    Nov 15 '18 at 8:19















2














Positive lookbehind is not supported by most browsers so use an alternative way to get your answer.



Something like this,



var string = "somestring(12)";
var exp = /(?:()(d+)(?:.d+)?(?=))/;
var mat = string.match(exp);

if(mat)
console.log(mat[1]);// second index



This should only give 12 as the answer






share|improve this answer

























  • it has problem, please check it https://regex101.com/r/eNOcvx/2

    – Ehsan Ali
    Nov 15 '18 at 8:12







  • 1





    The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

    – Simba3696
    Nov 15 '18 at 8:19













2












2








2







Positive lookbehind is not supported by most browsers so use an alternative way to get your answer.



Something like this,



var string = "somestring(12)";
var exp = /(?:()(d+)(?:.d+)?(?=))/;
var mat = string.match(exp);

if(mat)
console.log(mat[1]);// second index



This should only give 12 as the answer






share|improve this answer















Positive lookbehind is not supported by most browsers so use an alternative way to get your answer.



Something like this,



var string = "somestring(12)";
var exp = /(?:()(d+)(?:.d+)?(?=))/;
var mat = string.match(exp);

if(mat)
console.log(mat[1]);// second index



This should only give 12 as the answer







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 8:33









Ehsan Ali

47511032




47511032










answered Nov 15 '18 at 6:40









Simba3696Simba3696

267




267












  • it has problem, please check it https://regex101.com/r/eNOcvx/2

    – Ehsan Ali
    Nov 15 '18 at 8:12







  • 1





    The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

    – Simba3696
    Nov 15 '18 at 8:19

















  • it has problem, please check it https://regex101.com/r/eNOcvx/2

    – Ehsan Ali
    Nov 15 '18 at 8:12







  • 1





    The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

    – Simba3696
    Nov 15 '18 at 8:19
















it has problem, please check it https://regex101.com/r/eNOcvx/2

– Ehsan Ali
Nov 15 '18 at 8:12






it has problem, please check it https://regex101.com/r/eNOcvx/2

– Ehsan Ali
Nov 15 '18 at 8:12





1




1





The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

– Simba3696
Nov 15 '18 at 8:19





The first parenthesis is shown as 'matched' string but when you get the matched group it will come out as number only

– Simba3696
Nov 15 '18 at 8:19



這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3