Hi Team,
Can anyone please help me with regex to replace every number in string having following with space.
Example
1. Test 2121k$ test data :--> Test test data
2. Test 2121k€ test data :--> Test test data
3. Test 1000k CHF test data set :--> Test test data set
4. Test 1000k EUR test data set :--> Test test data set
5. Test 1000k USD test data set :--> Test test data set
Thanks
Bihitak
Discussion posts and replies are publicly visible
bihitakdass
Let me know if that works for you.
regexreplaceall("\d+k\s*(?:[$€]|CHF|EUR|USD)", PUT YOUR STRING HERE ," ")
Hi Shubham,Thanks this worked to certain extent but can you also suggest something for
1. Test 0.5M EUR Test :--> Test Test
2. Test 2121K€ test data :--> Test test data
3. Test 110EUR test data :--> Test test data
4. Test 7.95USD test data :--> Test test data
This k can be in caps also like 211K and not just K, it can be Billion("b" ,"B") ,Million( "m" , "M")
So can you help in modifying the regex to accept
The pipe character in RegEx acts as an "OR" operator - so you can extend the RegEx pattern accordingly:
regexreplaceall("\d+[k|K|m|M|b|B]\s*(?:[$€]|CHF|EUR|USD)", ri!data ," ")
Shubham Aware "(?:[$€]|CHF|EUR|USD)" can you please share the purpose of ?: in this regex?
bihitakdass Let me know if that works for you
regexreplaceall( "\b\d+(\.\d+)?[kKmMbB]?\s*(?:[$€]|CHF|EUR|USD)\b", PUT YOUR STRING HERE, " " )
Yogi Patel (?:) is used for non-capturing groups.?: says "find any of these on the list," but you don't need to remember which one you actually found later.