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

84 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,834
  • 15
  • 68
  • 140
13
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
  • 157
  • 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
  • 11,900
  • 22
  • 62
  • 102
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,867
  • 5
  • 20
  • 23
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
4
votes
2 answers

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…
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
  • 333
  • 2
  • 14
3
votes
4 answers

How to match )\n{ using sed?

I need to write a shell script which will input a string in my .c files after a quite complicated pattern to match. The pattern is: )\n{, without any tabs/spaces between the \n and the {. That's to say that I want to match with a { located in the…
aboitier
  • 180
  • 11
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
  • 214
  • 1
  • 12
3
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,530
  • 3
  • 22
  • 55
2
votes
1 answer

Finding if a string start with 0 or more spaces followed by a string that might contain metacharacters

I need to find if a string start with 0 or more spaces followed by a comment string I don't know in advance, so I though of just constructing the pattern: local pattern = "^(%s" .. comment_string .. ")" if str:find(pattern) then -- ... The problem…
Ludo
  • 21
  • 3
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
  • 810
  • 2
  • 12
  • 26
2
votes
1 answer

Python Regular Expression and Metacharacters

There is a variable which is: line="s(a)='asd'" I am trying to find a part which includes "s()". I tried using: re.match("s(*)",line) But it seems that It is not able to search for characters that includes ( ) Is there a way to find it and print…
kgb26
  • 183
  • 2
  • 14
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
  • 175
  • 1
  • 10
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
1
2 3 4 5 6