regex

How to allow only WhatsApp format numbers in a regex?

纵饮孤独 提交于 2021-01-20 08:52:34
问题 so I'm trying to make this Regex allow this the Dash symbol - For Example this Phone Number is not matching right now +212 659-123456 So I need someone to help me change the Regex to allow it please Here is the Regex: ^\+(?:[0-9]\x20?){6,14}[0-9]$ Because I am trying to only accept the format that is used by WhatsApp and some numbers might have multiple spaces or multiple Dashes. Also the Plus sign has to be mandatory Here some more examples of the format on WA. +96274567123 +967773-123-123

How to allow only WhatsApp format numbers in a regex?

雨燕双飞 提交于 2021-01-20 08:52:24
问题 so I'm trying to make this Regex allow this the Dash symbol - For Example this Phone Number is not matching right now +212 659-123456 So I need someone to help me change the Regex to allow it please Here is the Regex: ^\+(?:[0-9]\x20?){6,14}[0-9]$ Because I am trying to only accept the format that is used by WhatsApp and some numbers might have multiple spaces or multiple Dashes. Also the Plus sign has to be mandatory Here some more examples of the format on WA. +96274567123 +967773-123-123

Regex exec() loop never terminates in JS

天涯浪子 提交于 2021-01-20 07:26:40
问题 var matches; while(matches = /./g.exec("abc")) { console.log("hey"); } This never terminates. I expect it to terminate after 3 loops. Warning: Don't run it in Chrome because the infinite log lines freeze your entire system. It's safe to run it in IE (it still freezes your webpage but you can go to the location bar and press enter to reload). 回答1: This is how you should execute exec in a loop: var matches; var re = /./g; while(matches = re.exec("abc")) { if (matches.index === re.lastIndex) re

Powershell regex for replacing text between two strings

人盡茶涼 提交于 2021-01-19 11:37:13
问题 I am trying to use a powershell script to change the password between two strings, I am running into two issues. A complex password seems to break my regex, If I use something as simple as "TestPassword" the regex does what I expect. However using a more complex password "6QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" it breaks and results in SSLEnabled="true" keystoreFile="C:\cert.pfx" $16QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" keystoreType="PKCS12"/> instead of SSLEnabled="true"

Powershell regex for replacing text between two strings

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-19 11:36:48
问题 I am trying to use a powershell script to change the password between two strings, I am running into two issues. A complex password seems to break my regex, If I use something as simple as "TestPassword" the regex does what I expect. However using a more complex password "6QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" it breaks and results in SSLEnabled="true" keystoreFile="C:\cert.pfx" $16QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" keystoreType="PKCS12"/> instead of SSLEnabled="true"

Powershell regex for replacing text between two strings

僤鯓⒐⒋嵵緔 提交于 2021-01-19 11:33:59
问题 I am trying to use a powershell script to change the password between two strings, I am running into two issues. A complex password seems to break my regex, If I use something as simple as "TestPassword" the regex does what I expect. However using a more complex password "6QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" it breaks and results in SSLEnabled="true" keystoreFile="C:\cert.pfx" $16QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" keystoreType="PKCS12"/> instead of SSLEnabled="true"

Powershell regex for replacing text between two strings

試著忘記壹切 提交于 2021-01-19 11:33:10
问题 I am trying to use a powershell script to change the password between two strings, I am running into two issues. A complex password seems to break my regex, If I use something as simple as "TestPassword" the regex does what I expect. However using a more complex password "6QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" it breaks and results in SSLEnabled="true" keystoreFile="C:\cert.pfx" $16QAfD5PmMhWzUxTq1FO1bGJQQXRXu6tizN29h6MRUSI=" keystoreType="PKCS12"/> instead of SSLEnabled="true"

Sed failed to match non whitespace characters with character class

拟墨画扇 提交于 2021-01-19 06:32:31
问题 I want to extract filter rules configured in /etc/lvm/lvm.conf , like filter = [ "r|/dev/sda|" ] . I want sed to return "r|/dev/sda|" . So I have tried the following script: echo ' filter = [ "r|/dev/sda|" ] ' | sed -r 's:^\s*filter\s*=\s*\[\s*([^\s]+)\s*\]:\1:g' But it didn't work, the script has returned filter = [ "r|/dev/sda|" ] . I've tried a few on line regex tester, the group has been matched correctly. However, if I replace [^\s]+ by .+ , it works. Doesn't [^\s]+ mean more than one

Find overlapping Regexp matches

旧巷老猫 提交于 2021-01-18 05:41:02
问题 I want to find all matches within a given string including overlapping matches. How could I achieve it? # Example "a-b-c-d".???(/\w-\w/) # => ["a-b", "b-c", "c-d"] expected # Solution without overlapped results "a-b-c-d".scan(/\w-\w/) # => ["a-b", "c-d"], but "b-c" is missing 回答1: Use capturing inside a positive lookahead: "a-b-c-d".scan(/(?=(\w-\w))/).flatten # => ["a-b", "b-c", "c-d"] See Ruby demo 回答2: I suggest a non-regex solution: "a-b-c-d".delete('-').each_char.each_cons(2).map { |s| s

Find overlapping Regexp matches

橙三吉。 提交于 2021-01-18 05:39:12
问题 I want to find all matches within a given string including overlapping matches. How could I achieve it? # Example "a-b-c-d".???(/\w-\w/) # => ["a-b", "b-c", "c-d"] expected # Solution without overlapped results "a-b-c-d".scan(/\w-\w/) # => ["a-b", "c-d"], but "b-c" is missing 回答1: Use capturing inside a positive lookahead: "a-b-c-d".scan(/(?=(\w-\w))/).flatten # => ["a-b", "b-c", "c-d"] See Ruby demo 回答2: I suggest a non-regex solution: "a-b-c-d".delete('-').each_char.each_cons(2).map { |s| s