Skip to content

Tag: regex

How to check if string has repeating pattern?

I was recently asked this in an interview question: Given a input string check if it has repeating pattern and return true or false. For example: “abbaabbaabbaabba” is a repeating pattern of “abba” How can we solve it using regex and also without regex? I am interested in both the appr…

Remove character ‘u202A’ 8234 from string

I am trying to get character at 0 index in a string: So I use this function after I query contact, but I found strange result. Normal input & output: And this the strange input and result: So I try to debug this account and I found when app try to get character at 0 the return is ‘u202A’ 8234,

Java Regex First Name Validation

I understand that validating the first name field is highly controversial due to the fact that there are so many different possibilities. However, I am just learning regex and in an effort to help grasp the concept, I have designed some simple validations to create just try to make sure I am able to make the …

Java Stream filter with regex not working

hope somebody can help me. I have a ArrayList of a Invoice class. What I’m trying to get is to filter this ArrayListand find the first element which one of its properties matches with a regex. The Invoiceclass looks like this: I’m filtering with this regex (\D+) in order to find if there is any va…

how to remove Arabic hashtags?

I am polling tweets from twitter using Twitter4j and I am trying to filter hashtags from it after I take text from it I turn it into strings now I have this String: “892698363371638784:RT @hikids_ksa: اللعبة خطيرة مرا ويبي لها مخ و تفكير و مهارة👌🏻💡 متوفرة في #متجر_هاي_كيدز_الالكتروني ..” I want to…

Java regex does not match as expected

I’m starting with regex in Java recently, and I cant wrap my head around this problem. Result: Did not Match(Unexpected result) Explain this I get the output “Did not match.” This is strange to me, while reading https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html, I’…