+ 2

Write a regex that matches 'ab' if a and b are both numbers and their sum equals 10.

How do we write the above regex? Edit: examples: Matches: 55, 73, 91 Doesn't match: six4, a234, 145, 2a8, 2.08.0, 010

22nd Jul 2018, 8:18 AM
Satyam
6 Antworten
+ 3
Just in case anyone is reading this in the future. I found a simple way to cheat. https://code.sololearn.com/ca8r7j5hkX4A/?ref=app
14th Aug 2018, 2:22 PM
Satyam
+ 1
Can you please provide example?
22nd Jul 2018, 9:49 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 1
doubt this can be done as regex can't really do things such as add numbers
22nd Jul 2018, 11:53 AM
hinanawi
hinanawi - avatar
+ 1
This task is better done by dividing it in two parts: first extract all digit pairs and second, filter those that add up to 10.
22nd Jul 2018, 12:44 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
hinanawi ok....... Thank you! That's a great idea Kuba Siekierzyński! filter() KA-CHHING! Why didn't I think of that? Thank you!
22nd Jul 2018, 3:14 PM
Satyam