+ 11

Since JavaScript RegExp doesn't allow LookBehind, how can I achieve same results with another way?

Explain only with RegExp.

23rd Dec 2016, 9:24 PM
Valen.H. ~
Valen.H. ~ - avatar
6 odpowiedzi
+ 7
Lentin, do you have some random regex that you want to match? If no, I'll use a random one as expression. var str = "Valentinhacker is a hacker" ; If you want to capitalize the H in your name, using lookbehind will be something like, str = str.replace(/(?<=Valentin)./, char => char.toUpperCase()) (is it correct?) But since lookbehinds are not available, you can do str = "Valentin" + str.match(/Valentin(.)/)[1].toUpperCase() + "acker". Btw, if you have sth to match, I can help you.
8th Jan 2017, 1:31 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 5
I've read somewhere that it's indeed done by reversing but i don't know how to reverse...^_^
24th Dec 2016, 7:25 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
I asked this question because i had trouble with my code "Table Builder" but i found a workaround ^_^
8th Jan 2017, 1:35 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
You can reverse a String using the following: function reverse(s) { return s.split('').reverse().join(''); }
8th Jan 2017, 1:15 PM
James Flanders
+ 3
As I'm reading this fascinating topic and pondering who wrote the first RegEx parser, I note that lookahead is fully supported. And I wonder...would reversing the string be a useful start?
23rd Dec 2016, 10:25 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Yes, I tried using ?<= but it says invalid regular expression -_-
8th Jan 2017, 4:34 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar