w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » REGEX » Page 1
retrieving date of system boot with regex
You can set your locale to another language just for this specific command: LANG=xxx command. I have a French output too if I don't set LANG. So : $ LANG=C who -b | awk -F'boot *' '{print $2}' Nov 2 14:19 or : $ LANG=C who -b | sed 's/.*boots*//' Nov 2 14:19

Categories : Regex

Regular Expressions New line issue
You mentioned you're using C#, but didn't mention how you're using the regex. I'm assuming you're just doing simple validation for the existence of a link within the string. If you do a simple Regex.IsMatch() or Regex.Matches(), then it will search across the new line boundaries. If you provide which function you're using it'd make it easier to explain why your version is not working, but there's

Categories : Regex

RegEx in grep statement
To make the lookbehind to work , you need to enable -P perl-regexp parameter and also you need to enable -o only-matching parameter on grep to print only the match instead of printing the whole line. grep -oP "s?(?<='username' => ')[^']*" file OR grep -oP "'username' => 'K[^']*" file

Categories : Regex

Pattern matching with regexes in Scala
Change val isGovt = """Govt .*""".r to val isGovt = """(Govt .*)""".r When you use a regex as an extractor, the bound variables correspond to the regex's groups. Your regex had none. You could also simply keep your regex as is and do: case isGovt() => This is probably more like hat you had in mind.

Categories : Regex

Regex lines with exactly 4 semicolons
[EDIT: Fixed stupid bug...] The following will work with grep or any regex engine: ^[^;]*;[^;]*;[^;]*;[^;]*;[^;]*$ When used in a command line, make sure you put it inside quotes (" on Windows; either kind on *nix) so that special characters aren't interpreted by the shell.

Categories : Regex

Regexp for multiple keywords matching
You need to separate the matches in this particular case, or else you won't be able to distinguish between a username or a password. I would advise using one regexp for the username and another for the password. Next, change the regexp so that the character class is [^;]+ instead of [a-z0-9]+ to match all characters except ;. set value "colour=blue; age=25; name=anthony; username=firstuser; usern

Categories : Regex

Mark every line that ends NOT with specific character in sublime 2
You can use a look behind assertion as (?<!.) replace with space For example http://regex101.com/r/oS2qZ8/1

Categories : Regex

Regex / sed - how to match the last space character in a line before a 72 character limit
You can use: sed 's/.{72}[^[:blank:]]*[[:blank:]]*/& /g' msg.md [^[:blank:]]* will match 0 or more non-spaces after 72 characters followed by [[:blank:]]* which is zero or more spaces.

Categories : Regex

IntelliJ / PyCharm navigate by Regex
first of all your cocbas search is not "regex" search. In intellij, you can search file by pressing ctrl-shift-n, then you can for example: for file fooo/bar/blah/IAmHere.html do f/b/b/iam you will see the file in the list, in fact you can just typeiah the file would be shown in list too.

Categories : Regex

String Replace - address abbreviations
Deleting one chunk out of a word can be accomplished using MariaDB's regexp_replace and positive look-ahead and look-behind assertions. For Bayou and Boulevard I use replace. select replace(replace( regexp_replace( 'North East South West Alley Anex Arcade Avenue ' 'Bayou Beach Bend Bluff Bluffs Street Road Drive Boulevard', '(?<=N)orth|(?<=S)outh|(?<=E)ast|(?<=W)est|(?&

Categories : Regex

Regular Expression for Google Analytics Goals (Require Query String Parameters)
Try this : ^https(?=.*result=success)(?=.*action=upgrade).* for testing you can try here: http://rubular.com/r/hXYcRL1lSw I have tested your example only.

Categories : Regex

Regular expression to match string containing character
Your regex can search over multiple lines. If it doesn't there is a mistake in your code outside of it. (hint: [^'] does include newlines). How about this expression (it prevents useless backtracking): '([^'$]*$[^']*)'

Categories : Regex

rewrite query sign in url
You can use following lines to remove "index.php?" RewriteEngine On RewriteRule ^index.php?(.*)$ http://www.domain.com/$1 [R=302,L]

Categories : Regex

Extracting values from a string in R using regex
You can use strsplit with sub ... > sub('\(User|\)', '', strsplit(x, ',')[[1]]) [1] "20" "10.25" It would probably be easier to match the context that you want instead. > regmatches(x, gregexpr('[0-9.]+', x))[[1]] [1] "20" "10.25"

Categories : Regex

Parsing out a number after a specific word appears
This is slightly complicated by the fact that they also occasionally say things like "winds as high as 32 mph". The following works, though there may be more edge cases that aren't accounted for: highD+(d+)D(?!mph) This searches for the word 'high', and then slurps all of the characters until it reaches a digit. It grabs the digits in a group, and then grabs the next non-digit character (this e

Categories : Regex

Match a username after a keyword
Using perl : $ perl -lne '/Added user (domain\fuser) to the group/ and print $1' file or $ perl -lne '/Added user (QdomainfuserE) to the group/ and print $1' file Output : domainfuser

Categories : Regex

See if the filename is also a part of the pathname using Regular expressions
Here is the naive approach to do this: capture the filename (without extension) check the previous sections of the path for occurrences of that filename have the regex match/fail if the filename is found only once (i.e. never matched again) Bummer, regular expressions work from left to right, but the filename is at the end of the string. So we must find a way to match the filename first and ch

Categories : Regex

replace sections of top lines using regular expression
Assuming that the first | and # will always be where you want to cut off /(.*|)(.*?)s#.*$/$1 [$2]/ Since you didnt specify a language, I'm leaving it in generic form. Example link

Categories : Regex

How to compare two files in Python when line indices differ and regular expression has multiple matches?
trigger = ''' 10.792001 283292 30 11.286001 296136 9 11.792001 309292 130 17.898001 468048 23 18.390001 480840 9 18.896001 493996 123 24.988001 652388 73 25.482001 665232 9 25.988001 678388 173 34.026002 887376 10 34.518002 900168 9 35.024002 913324 110 40.676002 1060276 82 41.170002 1073120 9 41.67

Categories : Regex

readLines converts hyphen (-) to x
You are confused. It's not "x". The display of "xd1" is actually the display of a single character that does not have a representation in your font. It is a non-printing character (probably a "long dash") that is being displayed as an escape sequence. To get rid of it, you need to use gsub with extra backslashes because both R and regex use backslash as their escape character" gsub("\xd1", "_",

Categories : Regex

Delete regex and non-alphabet characters with grep/awk/sed
You can use cut to remove the prefix, for example: $ cat corpus.txt | cut -c 9- I didn't understand what you said . I know [!] &=laugh (.) . Then to remove the non-word tokens, you can use sed like this: $ cat corpus.txt | cut -c 9- | sed 's/&[^ ]*//g' I didn't understand what you said . I know [!] (.) . And finally, to remove non-alphabetic symbols and convert apostrophes to @, you

Categories : Regex

Group documents using substring of a field
You can get your results using the below aggregate pipeline operations. Sort the rows based on their hierarchy, so that the manager comes on top. Group together records that start with similar ancestors.(i.e 1.1 or 1.2,...). The manager record will be on top for each group due to the above sort operation. Take the count of each group, so the number of subordinates will be count-1(the manager rec

Categories : Regex

Nginx deny folder, allow subfolder
Use regular expressions : location ~ /assets/themes/default/(css|js)/(min|source)(?!/include) { deny all; } Your allow all; statements and surrounding location blocks are no more useful after this.

Categories : Regex

Find array of all matches of sub expressions efficiently in perl
In list context, when a //g match has no captures, it returns what matched. If it has captures, it returns just the captured values. my @values = $xml =~ m{<value>(d+)</value>}g;

Categories : Regex

Invalid regular expression: /(/: Unterminated group
You don't need to loop through invalid characters. Just use regex like this: var invalid = /[°"§%()[]{}=\?´`'#<>|,;.:+_-]+/g; var repl = toCheck.replace(invalid, "");

Categories : Regex

How to get all substrings from captured groups in regex in Vala?
What I need to do is to somehow get an array of all hashtags in string to use it to wrap all of them in tags. How can I do it? No it isn't. Try something like this: private static int main (string[] args) { try { GLib.Regex hashtagRegex = new GLib.Regex ("#([a-zA-Z0-9_\-]+)"); string res = hashtagRegex.replace_eval ("foo #bar baz #qux qoo", -1, 0, 0, (mi, s) => {

Categories : Regex

Regular expressions making scraper
try this: $re = "/<a[^"]*href="([^"]*)"[^>]*>([^<]+)<\/a>/mi"; $str = "<a id href="sjdkg">...</a> <a id href="sjdkg">.dg..</a>"; preg_match_all($re, $str, $matches); $matches[1]; // for href $matches[2]; // for innertext var_dump($matches); output: array 0 => array 0 => string '<a id href="sjdkg">...</a>' (length=26)

Categories : Regex

Match the text in two lines using sed in linux
What I would do : sed '/#error value for eg1/{h;n;s/$text=1/$text=0/}' file and if you have user input like your comments seems to say : input=$1 # first argument of the script # double quotes mandatory here for the variable `$input` to be evaluated : sed "/#error value for $input/{h;n;s/$text=1/$text=0/}" file

Categories : Regex

Regular expression not working as planned
I've browsed the regex docs of Qt. Jumping to the quantifiers section, it seems there's no way to make your quantifier lazy/ungreedy unlike in perl style regexes where you might add ? after your quantifier. Reading the note in the quantifiers section it seems you will need to use setMinimal(). Here's a code sample: QString str = "<div class="_ss"> <div class="info">

Categories : Regex

The difference between the language of regular expressions and regular strings
The difference between the language of regular expressions and regular strings Regular expression is regular automata, regular expression is expressed rules of a language which tells you that the given string is satisfying the rules or not, if it is satisfying then it is regular string (accepted by a regular language) because satisfied by a regular automata/ regular expression. If not accepted by

Categories : Regex

Trying "simple" parsing w/ antlr4 to reformat / pretty-print
Try this grammar: grammar NestedParens ; init: STR* ( '(' value (value)* ')' ) STR* ; value: init | STR ; STR: [^()]+ ; The difference is one missing * which made the empty string matching init in your version (the error that the antlr compiler complained about) no longer match. This would also work: grammar NestedParens ; init: STR* ( '(' value (value)* ')' )+ STR* ; value: init

Categories : Regex

Regex to append comma to numbers
Use capturing groups. Regex: ^('d{6})$ Replacements tring: $1, DEMO

Categories : Regex

Combine two regexes
The spaces in your combined expression are erroneous. You are requiring a space after end of line or before beginning of line, which is impossible in line-oriented input. As a further improvement, you can remove the superfluous "anything" parts of the match, as well as a good number of redundant parentheses. javax.faces.resource|rfRes|.(jpeg|gif|png)s*$ Notice also the proper quoting of liter

Categories : Regex

mod_rewrite - get domain and tld
You can replace your current code by this one RewriteMap whitelist txt:whitelist.map RewriteEngine On RewriteCond %{HTTP_REFERER} ^http://(?:.*?)([^.]+.[^./]+)/ [NC] RewriteCond ${whitelist:%1|NOTFOUND} NOTFOUND RewriteRule ^ http://www.somewhere-else.com [R,L] Note: this code assumes that whitelisted domains are first-level domains (not like .co.uk for example)

Categories : Regex

Creating a hash with keys and values selected from between points in a string
Hi Khuram and welcome to Stackoverflow :-) It seems you may have dropped your question but I'm adding this answer to make it more complete and potentially useful to others who find it. As @mappec suggested, you should consult the Bioperl website where you may find more resources. While there may be simpler ways of doing this, I like your idea of creating a hash to store the cut sites is a good

Categories : Regex

Regex Validation Kornshell
Your function can be just this: fn_validate_msisdn() { MSISDN=$1 REGEX_PTN="^((?+?(44|0{1}|0{2}4{2})[1-9]{1}[0-9]{9})?)?$" echo "$MSISDN" | egrep -q "$REGEX_PTN"; } then: fn_validate_msisdn 43743874874387439843 echo $? 1 fn_validate_msisdn 447999999999 echo $? 0 Remember return status of 0 means success and 1 means failure here.

Categories : Regex

RegEx to match certain string in sentence if a criteria is matched
Simple. Just run the normal regex for this, but include This_Criteria in the beginning of it. If it can't find This_Criteria, it will not match. But, if you are asking for people to do your regex for you... Depending on how specific you want the text to be, something like this should do the trick: /This_Criteria.*[[0-9]+]:(.*)/ This will match everything after the final [1033]: (any numbers), O

Categories : Regex

Regex - Get index of match in line
REgex: ^(w+) (w+)$ REplacement string: <span class="word1">$1</span> <span class="word2">$2</span> DEMO

Categories : Regex

Optional but not included trailing shash?
You can use this regex in your pattern: RewriteRule ^page/(.+?)/?$ /index.php?page=$1 [L,QSA] Or else use this pattern if you just want to match /path/abc OR /path/abc/: RewriteRule ^page/([^/]+)/?$ /index.php?page=$1 [L,QSA]

Categories : Regex




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.