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>

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 }
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.
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
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
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

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .