0

Why is this regex not working ?

I'm trying to use regex to output true if the string meets the requirements, but it keeps outputting false .Can someone please help me. https://code.sololearn.com/cx0q3osoWwrP/?ref=app

29th Apr 2020, 3:15 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
6 Answers
+ 3
It works if you correctly copy what I've done: https://code.sololearn.com/cWs1P62ZIWX2/?ref=app
29th Apr 2020, 3:36 PM
visph
visph - avatar
+ 3
Here's a solution using a single RegEx pattern. I also include a set of positive and negative tests to ensure a variety of value samples for expected PASS / FAIL scenarios. https://code.sololearn.com/c9VnW585YuDL/
3rd May 2020, 4:57 AM
David Carroll
David Carroll - avatar
+ 1
Not experiemenced at C#, but knowing regex: by correcting only all your regex, I get your expected True... but I don't know what are your exact requirements, so cannot be sure that all cases will be ok: Regex Length = new Regex(@"^.{5,10}
quot;); Regex Number = new Regex(@"[0-9]"); Regex Specialchar = new Regex(@"[^ÂŁ$]"); Regex nospace = new Regex(@"\S");
29th Apr 2020, 3:27 PM
visph
visph - avatar
+ 1
Thank you visph.
29th Apr 2020, 3:40 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
+ 1
But you need to redo your regex study... at least try to understand why your regex didn't work as expected (you could log each by each result, rather than just checking all at once, to better see where there are problems ^^)
29th Apr 2020, 3:43 PM
visph
visph - avatar
0
Sorry, visph it didn't work, but thank you.
29th Apr 2020, 3:31 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar