Questions tagged [metacharacters]

metacharacters are non-alphanumeric characters which are part of the processing model of a program rather than the literal value of a string

References

79 questions
0
votes
1 answer

regular expressions metacharacters screening

To find substring I use regEx pattern = "^value\s\w+\s\d+$", where value sometimes contains metacharacters. I just need to know if it is possible to make metacharacters from value not to be interpret as metacharacters?
Bor1ss
  • 29
  • 7
0
votes
0 answers

JQuery selector with meta-character using literals

I know there are a lot of threads about using meta-character in jQuery selector, but I promise this is unique. I've an html div element with meta-character in its id. Like below,

Click ME

Kay
  • 323
  • 3
  • 14
0
votes
2 answers

Sub-pattern in regex can't be dereferenced?

I have following Perl script to extract numbers from a log. It seems that the non-capturing group with ?: isn't working when I define the sub-pattern in a variable. It's only working when I leave out the grouping in either the regex-pattern or the…
EverythingRightPlace
  • 1,189
  • 11
  • 33
0
votes
3 answers

confusion in Meta characters of perl

When I run the below program, it gave me nothing ("") as result. Scenario 1:- $var = "A STITCH IN TIME SAVES NINE"; if ($var =~ /[1..9]/i) { print "FOUND\n" } But when I add space before and after '..' operator, it threw "…
Praveen kumar
  • 517
  • 2
  • 12
  • 26
0
votes
1 answer

How to match a String having metacharacters using regex matches function in Java

What could be the regular expression to match below String String str = "\r\n regular"; There is a carriage return "\r", new line character "\n" and a space after . My code is as…
Suvasis
  • 1,431
  • 1
  • 24
  • 40
0
votes
1 answer

Replace Strings in java having metacharacters

I have two strings and want to replace one string from the other. The problem is that strings have meta characters. E.g. String string1 = "I am foo"; String string2 = "I am bar and I am foo. I am both."; string2 = string2.replaceAll(string1, "");…
user2200660
  • 1,181
  • 3
  • 17
  • 23
0
votes
2 answers

Regex in Java: a*

Do you know why in a simple regex pattern if put a*(quantifier) it does not match any result in the matcher even though it actually contains the character a; (in any case it should give back a result of having found an empty string as I am using…
Rollerball
  • 11,004
  • 22
  • 81
  • 136
-1
votes
2 answers

Perl, pattern matching and metacharacters

I am trying to match two things which both are full of metacharacters that needs to be used as 'Literal' in my match pattern. \Q is suppose to quote all metacharacter in a string until \E...but it doesn't work. Whats up with that? this is the line…
-1
votes
1 answer

How to extract the second part of the string after the backslash in R?

I have a string 'ABC1\001ABCEFCGJS' I want to extract only 001ABCEFCGJS from this string How to do so in R? My String will be a dynamic string. So the solution should be such that function can read anything after backslash.
Arpit Gupta
  • 57
  • 1
  • 7
-1
votes
1 answer

Escaping meta characters in PHP

I was surprised to discover that the MySQL query SELECT * WHERE name LIKE "%AFA_"; returns rows where name is SAFARI. To get it to match on the underscore, you have to do: SELECT * WHERE name LIKE "%AFA\_"; Is there a PHP function that can do…
Scott C Wilson
  • 16,711
  • 9
  • 54
  • 76
-1
votes
1 answer

String contains any but one character

I want to check if a String contains a } with any character in front of it except \. As far as I know I can use . as a metacharacter in aString.contains(...) to allow any character at that position but I don’t know how to create something like a…
Nightfighter001
  • 460
  • 9
  • 22
-1
votes
1 answer

Perl: quoting correctly all special characters

I have this sample string, containing 2 backslashes. Please don't ask me for the source of the string, it is just a sample string. my $string = "use Ppppp\\Ppppp;"; print $string; Both, double quotes or quotes will print use Ppppp\Ppppp; Using my…
Claude
  • 171
  • 7
-1
votes
2 answers

How can I properly stop and start metacharacter interpolation in regexp in Perl

Editing to be more concise, pardon. I need to be able to grep from an array using a string that may contain one of the following characters: '.', '+', '/', '-'. The string will be captured via from the user. The array contains each line of the file…
WetCheerios
  • 125
  • 7
-1
votes
1 answer

Can metacharacters be used in a regular expression as a normal character?

I was wondering if metacharacters, such as ? or *, can be used in a regular expression as a normal character instead of metacharacters. For example, I have the following text: "Hi. How are you? What time is it? Beep?" And I wanted to use regular…
-2
votes
3 answers

Java - Is it possible to store metacharacters like dot in a character variable?

Metacharacters like ., \, {, ^, |, ] can be escaped with the \ character. But char variables can only store exactly one character. So is it possible to store these special characters in char variables in Java? Maybe you only need to use the escape…
Ricky
  • 187
  • 10