Capture [a-zA-Z] except for specific sequence of characters ("PT")

I have this capturing subgroup in my regex statement. What I am trying to achieve is to add an exception to the bold/first matching group ([a-zA-Z]{2}) which should not match the specific word "PT". I am using VBScript.RegEx which is said to be similar to Javascript RegEx. ([a-zA-Z]{2}|[a-zA-Z]{1}\d{1}|\d{1}[a-zA-Z]{1}) Refer to the table below for the… Read More Capture [a-zA-Z] except for specific sequence of characters ("PT")

How to replace the last occurence of } in a multiline string in Javascript?

How to replace the last occurence of } in a multiline string in Javascript? The method from how to replace last occurrence of a word in javascript? doesn’t work in the case of a multiline string: "line1}hello\n}\nline2}abc".replace(/(.*)}/g, "$1"); // "line1hello\n\nline2abc" because in this case every } is replaced, which I don’t want. Note: it’s not… Read More How to replace the last occurence of } in a multiline string in Javascript?

Differences between new RegExp(pattern) and pattern.test(string)

I try to create a strong password rule for JavaScript with regex. However, i find a strange result using different approach. First approach (worked): const value = ‘TTest90()’; const firstApproach = /^(?=(.*[a-z]){3,})(?=(.*[A-Z]){2,})(?=(.*[0-9]){2,})(?=(.*[!@#$%^&*()\-_+?.]){2,}).{8,}$/.test(value); The variable firstApproach is true witch is intended result. The next approach is using the new RegExp like: const pattern = ‘/^(?=(.*[a-z]){3,})(?=(.*[A-Z]){2,})(?=(.*[0-9]){2,})(?=(.*[!@#$%^&*()\-_+?.]){2,}).{8,}$/’; const… Read More Differences between new RegExp(pattern) and pattern.test(string)

Java/Regex: Replace all values starting with % and upto but not include comma or quote?

I have the following string: test0,test1%something1,{"test2%something2","test3%something3", "test4"} I want to write a regex(via Java String.replaceAll) to get rid of all text between %(including) and comma or quote(excluding) such that I end up with: test0,test1,{"test2","test3", "test4"} I have following regex: (%.*?)[\,,\"] But this is also capturing the comma or the quote so that I end up… Read More Java/Regex: Replace all values starting with % and upto but not include comma or quote?

Split string with regex based on two conditions

I would like to split this string: lg:[:after]:hover:color-blue The two conditions are: Split by : If there’s a [], get the content (even if there’s a : inside) The result would be lg :after hover color-blue Possible inputs would be: [:after]:hover:color-blue hover:color-blue lg:hover:color-blue What I have so far: const regex = /(?:([^\:\[\]]+)|\[([^\[\]]+)\])/g; const matches =… Read More Split string with regex based on two conditions

Regexp to match a string that starts with 2 letters

I have the following string: AP00c8.8bf2.6b54 and I need a regexp to match it the following way: starts with "AP"00c8(4chars).4chars.4chars This is matching the whole string in 2 results: ^AP[a-zA-Z0-9]*|[a-zA-Z0-9]*\.[a-zA-Z0-9]+([a-zA-Z0-9]+)?$ So that is almost working, no I just need to limit the chars like 6.4.4 Anyone wanna lend me a hand? -Toube >Solution : If… Read More Regexp to match a string that starts with 2 letters

Python regular expressions to continuously extract multiple pieces of information from text data

I hope you are having a great day, I have a dataset that has a col named "plain_text" in which we have a dumped log of conversations among several user in a group chat, the servers saves the information in a format like this: a "timestamp" + "user name" + ":" + "text" the timestamp… Read More Python regular expressions to continuously extract multiple pieces of information from text data