how to Allow ! but block consecutive !! in regular expression in shell scripting in the below code

问题内容: #!/bin/bash default_pwd="mysql_password" script_pwd="template!123" echo $default_pwd echo $script_pwd if [ $default_pwd == $script_pwd ] then echo "They match" else if [ `expr "$script_pwd" : ".*[!]{2}$.*"` -gt 0]; then echo "Contain consecutive !! special character" else echo "valid password" fi fi Expected Result: it should echo “consecutive !! special character” when script_pwd has !! 问题评论:   

I want to extract m3u8 and wmsAuthSign by regex

问题内容: I could extract m3u8 and wmsAuthSign of below link by regex before but now my code doesn’t work! what’s the problem ?! Link : This is my regex code : $streamSite = ""; function writeFile($url, $channel) { $File = $channel.".strm"; $Handle = fopen($File, 'w'); fwrite($Handle, $url); fclose($Handle); } $input = @file_get_contents($streamSite) or die("Please

Regex for string between a digit and character?

问题内容: I have a few different strings that look like this: All I am interested in is the characters between the last numeric digit and the first full stop, ie b ccc dd eeee Is there a regular expression that can achieve this? 问题评论: 答案: 答案1: Try this pattern: .*\d+([^.]+)\. The

How to unescape escaped regex?

问题内容: I’m looking for the reverse of regexp.QuoteMeta. Is it there a such function? I’ve tried to manually unescape it using strings.Replace("\", "", -1) but this is prone to error/unreliable as it doesn’t work in all the cases(i.e. on excessive escaping or unicode). I also tried to add some quotes and use strconv.Unquote (e.g. strconv.Unquote(“+

PHP preg_match_all subpattern names in a pattern

问题内容: The task is pretty clear. In the input we have a variable regex pattern, which supposedly contains named subpatterns, and in the output we need to get an array of subpattern names: function get_subpattern_names($any_input_pattern) { // What pattern to use here? $pattern_to_get_names = '/.../'; preg_match_all($pattern_to_get_names, $any_input_pattern, $matches); return $matches; } So the question is