#4.17 LAB: Remove all non alpha characters
10 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wary mango! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
you can use a regex
[^A-Za-z] will match non-alphabetical characters
you can replace all of them using .replaceAll
if you are allowed to use regexes
if not, ho over all characters, check if it's alphabetical and remove them if they aren't
declaration: module: java.base, package: java.lang, class: Character
note: don't loop over the same string you're removing from, that causes issues
best way is to create a new string/stringbuilder from the chars that are alphabetical for a simple approach, or you could use streams and filter if you can use streams