1

Been trying to extract only accent characters[a particular word] from a multiple text files in a folder. Don't want to remove or convert accent characters to normal characters but print only those characters which are accent in multiple text files and mixed files which has both accent[words] and normal characters. in JAVA

**only to extract all accent specific words. ** after searching and exploring for a while this a link below is a type of one solution, similar regex but doesn't work as required also select null values and normal characters. Regex accented Characters for special field

another solution found for that is ([a-zA-Z]|[à-ü]|[À-Ü]) it selects each letter separately not feasible as it not word specific and also selects both normal and accent.

asked Feb 17, 2023 at 5:30
3
  • 1
    Please show your code with what you have tried already in a minimal reproducible example - Also read the How to Ask page for tips on how to improve this questions. Welcome to Stack Overflow - Take the tour (and earn a badge while at it) Commented Feb 17, 2023 at 6:21
  • Will definitely work on the way to ask question thanking you for pointing it out would read it clearly and update my question Commented Feb 17, 2023 at 9:10
  • Note that sometimes accented characters are represented using the base character plus a "combining diacritic" so à might be 'a' and U+0300 (combining grave diacritc). You can use java.text.Normalizer to deal with this. Commented Feb 17, 2023 at 9:55

1 Answer 1

1

If you want to match word that contains the accent letter you need to go with something like:

[a-zA-Zà-üÀ-Ü]*[à-üÀ-Ü][a-zA-Zà-üÀ-Ü]*

explenation:

  • [a-zA-Zà-üÀ-Ü]* - this will match all the accent and not accent letters (so we can have other accent/non-accent letters in our word) - the star * modifier is here to match zero or more letters
  • [à-üÀ-Ü] - this will match exactly one accent letter - to force matching only the words with an accent
answered Feb 17, 2023 at 7:17
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much for answering, it cleared the doubt and thanks for the good explanation

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.