w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories

How to match a question mark?


Use quotemeta for the regex pattern.

use warnings;
use strict;

my $search = quotemeta
'http://shorturl.com/detail.cfm?color=blue';
my $replace =
'http://shorturl.com/detaila.aspx?color=red';
my $file = '<a
href="http://shorturl.com/detail.cfm?color=blue"
class="news">HI</a>';
$file =~ s/$search/$replace/gis;
print $file;

__END__

<a
href="http://shorturl.com/detaila.aspx?color=red"
class="news">HI</a>

Categories : Regex

Related to : How to match a question mark?
regex match literal before question mark
With this small regex (?<=goodid\?=)d+ It uses a lookbehind that check behind the digit for goodid?= In C# it can look like string resultString = null; try { resultString = Regex.Match(yourstring, @"(?<=goodid\?=)d+", RegexOptions.Multiline).Value; } catch (ArgumentException ex) { // Syntax error in the regular expression }

Categories : C#
htaccess rewrite match question mark
RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(GET|POST) RewriteRule ^ws/([^/]+)/([^/]+)/([A-Za-z]+) index.php?type=$1&resource=$2&action=$3 [QSA,L] Notice the QSA flag so that the query string from the original URL is appended to the new URL.

Categories : Regex
Regex/Php: Cannot match question mark in live site
try \? instead of ? ; if that doesn't work, you might run a regex engine version which doesnt support negative lookahead. In that case you could reform your preg_replace to preg_replace('/([?&]p=1)([^d])/', '$2', $url) . '<p>'; which would consume the non-digit, but put it back in again. There might be edge cases where this differs from your regex, but I don't think you'd be able to

Categories : PHP
Python Regex: Question mark (?) doesn't match in middle of string
Regex d? simply means that it should optionally (?) match single digit (d). If you use something like this, it will work as you expect (match single digit anywhere in the string): d

Categories : Python
Perl Extended Regular Expressions - match with multiple question marks inside
? is called quantifier that makes preceding pattern or group an optional match. Independently ? doesn't make any sense in regex and you are getting an error like: Quantifier follows nothing in regex. Following regex should work for you in perl: ...[dD][eE][fF][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] OR even more concise regex: .{3}[dD][eE][fF][0-9]{9} Each dot means match any characte

Categories : Regex
© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.