question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce RegEx before "Check for Palindrome" problem

See original GitHub issue

Check for Palindrome continues to be difficult to surmount for beginners in JavaScript.

This challenge has two parts to it:

  • Process the input string str to remove non-alphanumeric characters from it.
  • Use some logic to find palindromes.

This is the third challenge in Basic Algorithmic Challenges, and the two that comes before this, introduce the camper to recursion and String-to-Array with reverse(), split(), and join().


In this challenge, the camper needs to come up with a non-trivial regular expression, to remove non-alphanumeric characters from the input string str.

And here’s the kicker - \w does correspond to alphanumeric characters [0-9] and [a-z] (and also [A-Z], but not relevant to this challenge, because we do case insensitive matching); but it also includes underscore _. The test cases indicate you have to exclude underscore.


I recommend introducing the camper to regular expression, with 1-2 problems before that, and teach them how to form and test their RegEx. At the very least, they should be able to use something like regex101.

Ideally, I would want a full-fledged curriculum dedicated only to RegEx. I have seen even experienced campers fear regular expressions (I am not experienced, but I fear it too!). If this issue is accepted, I can work with others on the core-team on getting a curriculum on RegEx on the live site.

I know that there are four problems that refers to regular expression:

But none of them makes the camper comfortable forming non-trivial complex regular expressions. And in later challenges, like US telephone numbers, regular expression makes the difference between solved and unsolved.

Besides, these four problems are from optional part of the curriculum. In the helpful links section for the palindrome problem, we can at least point them to these.

@QuincyLarson @BerkeleyTrue @SaintPeter @CodeNonprofit FYI.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
alayekcommented, Jun 20, 2016

@deesto the tutorial on regexone is cool! But it also has its deficiencies.

As I have mentioned above, it lets you continue without having to fully match Strings given. But the biggest problem I see with tutorials like regexone and similar others, is this: it’s isolated

Let me explain what I meant by that: most people learn RegEx step by step (groupings, tokens, extracting) then they move on with their life. They would never use it unless there is absolutely no other way.

You won’t use RegEx as often as you would use conditionals or loops or recursion in your code. Even when you would have to use, you would most likely Google for some existing ones and copy-paste for lack of time.

Our aim is to form the RegEx curriculum in a way that it feels organic, with lot of practical use-cases. We would like to make the camper feel at-home using regular expressions.

As for reinventing the wheel, it’s not a massive undertaking, compared to some of the things we have built so far and more so planning to build.

2reactions
SaintPetercommented, Jun 19, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduce RegEx before "Check for Palindrome" problem #9232
In this challenge, the camper needs to come up with a non-trivial regular expression, to remove non-alphanumeric characters from the input ...
Read more >
Coding the Impossible: Palindrome Detector with a Regular ...
I came across a Stack Overflow question which asks how to check if a string is a palindrome using regular expressions. The top...
Read more >
How does this Java regex detect palindromes? - Stack Overflow
So the basic algorithm is that we try to build a suffix, subject to a palindromic constraint, as we scan the string left...
Read more >
Can you match palindromes in regular expressions? - Quora
Yes, as long as there's only a certain length palindrome you're looking to match. which matches 3 characters and then those three characters...
Read more >
A few succinct ways to solve the Palindrome problem in ...
First, let's see the introduction of this challenge on freeCodeCamp: Return true if the given string is a palindrome. Otherwise, return false . ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found