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
35
votes
2 answers

Extended regular expressions (ERE) for .gitignore

Is there a way to use extended regular expressions(ERE) in a .gitignore file? For example I want to use the + repetition character in a .gitignore file. Is there a way to do that?
Jacob Krieg
  • 2,430
  • 10
  • 60
  • 114
10
votes
2 answers

Python: filename contains String (metachar?)

I'm using os.walk(directory) to show recursively all the files from that directory. The thing is that i need to show only the files that contain an asked String in its name, and it has to manage metachars too. What i have now is: for root, subdirs,…
Croc
  • 127
  • 1
  • 1
  • 10
6
votes
2 answers

Is there a simple way to switch between using and ignoring metacharacters in Python regular expressions?

Is there a way of toggling the compilation or use of metacharacters when compiling regexes? The current code looks like this: Current code: import re the_value = '192.168.1.1' the_regex = re.compile(the_value) my_collection = ['192a168b1c1',…
Juan Carlos Coto
  • 9,760
  • 18
  • 52
  • 95
6
votes
2 answers

How do I write regexes for German character classes like letters, vowels, and consonants?

For example, I set up these: L = /[a-z,A-Z,ßäüöÄÖÜ]/ V = /[äöüÄÖÜaeiouAEIOU]/ K = /[ßb-zBZ&&[^#{V}]]/ So that /(#{K}#{V}{2})/ matches "ßäÜ" in "azAZßäÜ". Are there any better ways of dealing with them? Could I put those constants in a module in a…
Owen_AR
  • 2,411
  • 5
  • 17
  • 20
5
votes
3 answers

strsplit in R with a metacharacter

I have a large amount of data where the delimiter is a backslash. I'm processing it in R and I'm having a hard time finding how to split the string since the backslash is a metacharacter. For example, a string would look like…
newRUser
  • 59
  • 1
  • 3
3
votes
1 answer

Substring between known two markers extraction with problem markers

@miernic asked long ago how do you extract an arbitrary string which is located between two known markers in another string. My problem is that the two markers include Regular Expression's meta characters. Specifically, I need to extract ABCD from…
MeirG
  • 309
  • 2
  • 12
3
votes
4 answers

How to match string that contain exact 3 time occurrence of special character in perl

I have try few method to match a word that contain exact 3 times slash but cannot work. Below are the example @array = qw( abc/ab1/abc/abc a2/b1/c3/d4/ee w/5/a s/t ) foreach my $string (@array){ if ( $string =~ /^\/{3}/ ){ print "…
Tim
  • 204
  • 1
  • 10
2
votes
1 answer

Dangling metacharacter * sparksql

Below regex works in Hive but not in Spark. It throws an error dangling metacharacter * at index 3: select regexp_extract('a|b||c','^(\\|*(?:(?!\\|\\|\\w(?!\\|\\|)).)*)'); I also tried escaping * with \\* but still it throws dangling metacharacter…
2
votes
1 answer

What is the difference between \\s+ and \s+

I know one of the regular expression is "\s+" which is mean one or more whitespaces. But in many referenece that I saw, Why they use double backslash "\\s+" instead of just one backslash "\s+" ? For exemple in this code that I get in stackoverflow…
alramdein
  • 436
  • 6
  • 15
2
votes
1 answer

How to Replace with Line Feed in VBScript RegEx

I am using VBScript and have a script that converts an xml to a text file. I am trying to do a replacement to replace the string ###EntryEnd###\| to a LF character. I tried \n and \x0a in the replacement pattern but they don't work. The only…
ib11
  • 2,306
  • 3
  • 17
  • 44
2
votes
1 answer

Escape all metacharacters in Python

I need to search for patterns which may have many metacharacters. Currently I use a long regex. prodObjMatcher=re.compile(r"""^(?P[\w\/\:\[\]\<\>\@\$]+)""", re.S|re.M|re.I|re.X) (my actual pattern is very long so I just pasted some…
Yogesh Luthra
  • 155
  • 1
  • 8
2
votes
3 answers

Is it possible to extend the range of a regex meta character?

I am working with js (javascript) regex literal expressions but I guess the answer applies to all regex in some form. I simply want to know if it is possible to do this: /\w+[more characters]/g (please disregard the incorrect expression, it is for…
micnolmad
  • 25
  • 6
2
votes
3 answers

R Regex: Parenthesis Not Acting as Metacharacter

I am trying to split a string by the group "%in%" and the character "@". All documentation and everything I can find says that parenthesis are metacharacters used for grouping in R regex. So the code > strsplit('example%in%aa(bbb)aa@cdef',…
esa606
  • 370
  • 2
  • 13
2
votes
1 answer

What are dangling metacharacters in regex?

In Ruby, I wrote a simple regex to find the first {: txt.gsub! /^.*{/, '{' Whenever I run this, everything past that point for my purposes works fine, however there is a mild error that reads along the lines of WARNING: Dangling metacharacter…
T145
  • 1,118
  • 1
  • 9
  • 28
2
votes
1 answer

pexpect and shell meta characters (>, |, or *)

I am pretty confused right now. pexpect documentation states the following: Remember that Pexpect does NOT interpret shell meta characters such as redirect, pipe, or wild cards (>, |, or *). This is a common mistake. If you want to run a command and…
theAlse
  • 5,217
  • 10
  • 57
  • 101
1
2 3 4 5 6