+ 7

[SOLVED] Why this is returning false?

Here's the code link: https://code.sololearn.com/WMDQHz9b3R0z/?ref=app

25th Jun 2021, 1:14 PM
‎Keshav
‎Keshav - avatar
13 Antworten
+ 9
because /re*ex/ search for 'r' followed by 0 or more 'e', then followed by 'ex'... instead try /re.*ex/ wich search for 're' followed by 0 or more any char, then followed by 'ex' ;)
25th Jun 2021, 1:29 PM
visph
visph - avatar
+ 5
‎Kêsh@v Use the "." And "*" together Like /re.*ex/ it will find any number occurance of any character including 0 occurance after "re"
25th Jun 2021, 4:13 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 4
‎Kêsh@v n* Matches any string that contains zero or more occurrences of n Means re*ex Will match reex (0 occurance of e) Will match reeex (1 occurance of e) Another example Ar*av Will match Arav (0 occurance of r) Will match Arrav (1 occurance of r) And so on if there would be any other characters other than the character that is precided by * it will not match
25th Jun 2021, 4:28 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 4
25th Jun 2021, 4:46 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
visph Thanks for your response But would you please elaborate in a better way? I didn't got you 😅
25th Jun 2021, 3:37 PM
‎Keshav
‎Keshav - avatar
+ 3
Arnav Kumar Yea I tried and it worked fine But needs explaination, why it's not working with only asterisk. The tutorial video I watched on YouTube, it was working fine there.
25th Jun 2021, 4:17 PM
‎Keshav
‎Keshav - avatar
+ 2
Assassin Period (.) symbol is used for only one character But if we use asterisk (*) here, it will be able to find match for more than one characters
25th Jun 2021, 3:43 PM
‎Keshav
‎Keshav - avatar
+ 2
Arnav Kumar Oh I see!! It means the every character should be the same in place of asterisk? Edit:- reeeeeeeex // true reeeeegex // false
25th Jun 2021, 4:33 PM
‎Keshav
‎Keshav - avatar
+ 2
Assassin no no 😅
25th Jun 2021, 4:38 PM
‎Keshav
‎Keshav - avatar
+ 2
visph Arnav Kumar Now I understand that! Thanks for the clarification 😊
26th Jun 2021, 5:28 AM
‎Keshav
‎Keshav - avatar
+ 1
* apply to the previous character (or group) in the regex pattern: /re*ex/ will match 'rex' (0 occurences of first e), 'reex' (1 occurence), 'reeex' (2 occurences)... and so on... . match any character, .* match 0 or more any character: /re.*ex/ will match 'reex' (0 occurences), 'regex' (1 occurence), 'reflex' (2 occurences)... and so on...
25th Jun 2021, 6:52 PM
visph
visph - avatar