w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to prevent duplicate email addresses from being registeres?
Add a unique constraint on the email column in the table members: ALTER TABLE members ADD UNIQUE (email); Typically, you would do this when you create the table rather than altering the table afterwards.

Categories : PHP

perl regex: stucked with regex capture
Sections like this if (defined $reply[$count]) { ($Reply{$Log_name}) = $reply[$count] =~ /Time for unzip reply=(d+) s./; printf "$Reply{$Log_name} "; } Become if (defined $reply[$count] && ($reply[$count] =~ /Time for unzip reply=(d+) s./) ) { ($Reply{$Log_name}) = $1 print "$1 "; } I assume some of your data matches /Time for unzip reply/ but not /Time for unzip reply=(d+) s./

Categories : Regex

How can I allow email addresses from two different domains using Regex?
By grouping the evaluation () and placing an or operator in it | you'll be able to handle either domain. See the below modified regex: 'email' => '/^[w.+-]{2,}@(DOMAIN1|DOMAIN2).[a-z]{2,6}$/',

Categories : PHP

Bash / Regex Parsing only Domain Names In File containing both Domans and Email Addresses
if your file contains only domain and email addr, try this line: grep -v '@' file test with your example: kent$ echo "john3525@aol.com brenda392@yahoo.com xyx.net boxers.on.ca helloworlds.co.uk"|grep -v '@' xyx.net boxers.on.ca helloworlds.co.uk

Categories : Regex

Capture $ in regex Python
The question mark at the start is the cause of the nothing to repeat error. >>> import re >>> re.compile(r'?') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/mj/Development/venvs/stackoverflow-2.7/lib/python2.7/re.py", line 190, in compile return _compile(pattern, flags) File "/Users/mj/Development/venvs/stackoverflow-2.7/lib/python2.7/re.py", line 242, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat Match the dollar plus digits and dots: r'$[d.]+' Demo: >>> re.search(r'$[d.]+', 'blah blah blah (blah $23.32 blah) blah blac (blah)').group() '$23.32'

Categories : Python

C++11 Regex Capture Groups By Name
You cannot name a capture group with the c++11 standard. C++11 regex conforms to the ECMAScript syntax. Here is a link that explains it all http://www.cplusplus.com/reference/regex/ECMAScript/. Even though this maybe disappointing if you think about it a true regular expression will not support this it is extra.

Categories : Regex

HTC Wildfire S, intent of camera capture has a duplicate copy in Gallery in addition to the specified output in ContentProvider
I find the issue that many programmers met: "Deleting a gallery image after camera intent photo taken" Originally I just used the EXTRA_OUTPUT, but I soon discovered the following: - Some devices use it completely and skip the gallery. - Some devices ignore it completely and ONLY use the gallery. - Some devices really suck and save a full sized image to the gallery, and save a thumbnail only to the location I wanted. (HTC you know who you are...) Hmm, you know who you are ... :) Or see "Android Camera intent creating two files"

Categories : Android

Regex to capture substring between quotes
By default, the * quantifier is "greedy", which means (.*) will match everything it possibly can. To restrict it such that it matches as little as possible, i.e. only until the next double-quote that occurs in the string, add a ? to it, thus: ($txid) = $content =~ m/<input name="transactionid" value="(.*?)" type="hidden">/; Assuming the value of the value attribute contains no escaped double quotes, this will produce the result you're after. (Of course, in cases where there are escaped double quotes, there is no regex which will reliably extract just the string of interest and nothing else. This is why people tell you not to use regexes as your sole tool for parsing balanced text. On the other hand, given the simplicity of your purpose here, you'll probably get away with it -- bu

Categories : Regex

Regex to capture tags fails when "src" value is different
The * quantifier is greedy: it matches as much as it can while allowing the rest of the pattern to match. In your case, S* is likely consuming more text than you intended. Consider using my @accept = $message_body =~ /<img src="S*?">/gi; or my @accept = $message_body =~ /<img src="[^"]+">/gi; These patterns attempt to stop matching as soon as they detect a closing double-quote, but they are heuristics that could fail depending on how friendly your input is. To do the job properly, use an HTML parser.

Categories : Regex

Regex: how to capture new line only if certain criteria are met?
I am not sure how to tell regex "look for this in a new line, if it's there, capture the line. if it's not there, just stay on the current line. You could just match the new line as part of an expression repeated multiple times, e.g: d{3}( d{3})* Not sure of the specifics of exactly what you want to match but this is the best I could come up with without further info...

Categories : Regex

Multiline regex capture in Scala
If you want to activate the dotall mode in scala, you must use (?s) instead of (?m) (?s) means the dot can match newlines (?m) means ^ and $ stand for begining and end of lines

Categories : Regex

Regex capture first/last word in a filename
Description This expression will: assumes the only interesting data from the file name exists before the first dot assumes the initials are three upper case, preceeded by a space, and will be followed by a dot capture the non initials and non date portion of the file name capture the entire file name upto but not including the first dot capture the initials if they exist capture the date if it exists allow date, initials and file to appear in any order if they exist in the filename For this I'm using the ^ (?=(?:[^.]*?(?<file>(?<=^)[a-zA-Zs]*?(?=s[A-Z]{3}.|s)|(?<=s)[a-zA-Zs]*?(?=.|s[A-Z]{3}.)))?) # get the file (aka not date and not initials (?=(?:[^.]*?s(?<Initials>[A-Z]{3}).)?) # get the initials (?=(?:[^.]*?(?<Date>d+))?) # capture the date value

Categories : C#

URL rewriting Regex with capture group
(?:/PeopleDirectory(?:/|))(.*) with replace /Explorer/PeopleDirectoryProxy.aspx?pdurl=$1 only 1 thing the .aspx will be used as a parameter you can exclude it in some way or i must exclude via regular expression?

Categories : Dotnet

Java Regex to capture several matches
I wouldn't use a regex for this. What about something along the lines of String[] split = s.split("/"); StringBuilder sb = new StringBuilder(s.lastIndexOf('/') + 1); // our result sb.append('/'); // initial "/" for (int i = 0; i < split.length - 1; i++) { // we don't care about the if (split[i].isEmpty()) // last component continue; sb.append(split[i]); sb.append('/'); System.out.println(sb); // or add to an array/list/etc. } /accounts/ /accounts/main/ /accounts/main/index/

Categories : Java

Search-and-replace regex with capture
You could do it like this: #!/usr/bin/perl use strict; use warnings; my $text = 'lis r3, ha16(L_.str10) some more text blah lis r3, lo16(identifier) some more text blah lis r3, ot16(identifier)'; $text =~ s/(w{2})d{2}(([w.]+))/$1 eq 'lo' ? $2 . '@l' : $2 . '@' . $1/gie; print $text; Can also be written as: #!/usr/bin/perl use strict; use warnings; while (<DATA>) { s/(w{2})d{2}(([w.]+))/$1 eq 'lo' ? $2 . '@l' : $2 . '@' . $1/gie; #you can also print out the result of the replacement. #print $_; } __DATA__ lis r3, ha16(L_.str10) some more text blah lis r3, lo16(identifier) some more text blah lis r3, ot16(identifier) To put it simple the e modifier allows you to use code on the right hand of the regex that can be used to replace the pattern. For a more detail

Categories : Regex

regex to capture any several words in a sentence
Here's a regex that matches 1 to 3 words between the words "key" and "has", and here's a link to a RegExr that tests it. I admit I'm not familiar with spamassassin but if all you need it a regex to match a line of text then this should work: key(s((w+s){1,3})has Using the braces {1,3} means that the previous token (in this case, the group (w+s)) must match at least once but no more than three times. The  token matches a word boundary, and s matches any whitespace. w, as you know, matches any alphanumeric character. If you need to, you can use backreferencing to extract group 1, which now contains the words between "key" and "has" (as well as the whitespace surrounding them). Hope this helps!

Categories : Regex

RegEx to capture repeating fields?
I'm trying this in VB (because that's what I have open), but consider iterating the Capture for the group: For Each m As Capture In response.Match(example).Groups("Field").Captures Debug.WriteLine(m.Value) Next gives me ALPHAONE BETATWO CHARLIETHREE

Categories : C#

Regex capture value within bracket, value contain brackets as well
A pretty simple way would be as follows if I'm understanding you correctly: 1. iterate through characters 2. find first left brace 3. count braces until non-paired right brace appears and store index 4. take the substring from zero to that index and set as value x 5. delete value x substring 6. go to step 1 and store next part as value y

Categories : C#

use a regex capture in a pgSQL select
Using a subselect and the substring method you should be able to achieve what you want like so: SELECT * FROM firstTable WHERE parentCat = (SELECT cat FROM secondTable WHERE cat in substring(column_to_capture_from from 'thomas-var-3="(.+?)' )); from http://www.regular-expressions.info/postgresql.html If there is a match, and the regex has one or more capturing groups, the text matched by the first capturing group is returned.

Categories : SQL

Regex: set capture to fixed string
There is no way to get anything in to a capturing group which isn't in the input string. Capturing groups are (at least in Perl) partially represented as start/end positions of the original input string. If the value you want the capturing group to get is in the input string you can do that using lookarounds. The desired string has to be after the match if your regex flavor has a limited lookbehind (like PHP). For example: preg_match('/a(?=.*(?<id>b))/', 'a foo b', $matches); print "matched '$matches[0]', id is '$matches[id]'"; Output: matched 'a', id is 'b'

Categories : Regex

Are memory addresses reported in valgrind absolute, physical addresses?
In modern processors / operating systems, memory is mapped into the process space of a program. The program has no notion (or interest in) the actual physical memory address of the space it's using--only device drivers really have the need.

Categories : Misc

Grep regex to capture ip socket without port
Simply use awk and split in characters {, :, } and blanks. Then count fields: awk -F'[{:}[:blank:]]+' '{ print $9, $11 }' infile It yields: 10.20.21.106 10.20.21.27

Categories : Regex

regex capture bind parameters following a colon
You just need a "look behind": (?<=:)w+ A look behind asserts, but does not capture, what comes before the match. Note the the whole match (not group 1 as in your regex) is your target. Also notice the simplification: w means exactly [a-zA-Z0-9_] . See this regex running on rubular

Categories : Javascript

Javascript Regex Pattern Capture - all possible combinations
this works for me var str='||1|| Jam Jam jambura jadu tu sikh jambura'; reg = /(?!||(d+)|||jambura).+?jambura/g; re = /(?![|]+)d+(?=[|]+)/ alert('page '+str.match(re)+': '+str.match(reg).length+' matches'); Try Fiddle the idea is to match ||d+|| first, then only jumbara. Actually, I spent half of a night to find a solution, so I don't remember why I started to use ?! here, but it works

Categories : Javascript

Performing regex capture and then substitute using SED/PERL
You can use escaped parenthesis to capture groups, and access the groups with 1, 2, etc. sed 's/^(.*).txt$/perl mycode.pl /home/neversaint/1.txt > /home/neversaint/1.output/' submit.sh output: perl mycode.pl /home/neversaint/dir1/pmid_5409464.txt > /home/neversaint/dir1/pmid_5409464.output perl mycode.pl /home/neversaint/dir1/pmid_5788247.txt > /home/neversaint/dir1/pmid_5788247.output perl mycode.pl /home/neversaint/dir1/pmid_4971884.txt > /home/neversaint/dir1/pmid_4971884.output edit: it doesn't look like sed has a built-in in place file editing (GNU sed has the -i option). It still possible to do but this solution just prints to standard out. You could also use a Perl one liner as shown here: sed edit the file in place

Categories : Regex

How do I write a regex to match and capture at the same time?
What you are looking for is puts "line#{$1}". The pseudo-globals $1, $2, $3, etc. refer to capture groups of the last Regexp match. (And $~ refers to the MatchData itself, if you'd like to work with that.)

Categories : Ruby

Regex for Finding a Suffix, but do not capture from Right to Left
Use lookahead, (?=), to find something but not capture it. .+(?=s+d{5}) You can see that this regex works using this online tool.

Categories : Dotnet

Ruby - best way to extract regex capture groups?
For simple tasks, directly accessing the pseudo variables $1, etc. may be short and easier, but when things get complicated, accessing things via MatchData instances is (nearly) the only way to go. For example, suppose you are doing nested gsub: string1.gsub(regex1) do |string2| string2.gsub(regex2) do ... # Impossible/difficult to refer to match data of outer loop end end Within the inner loop, suppose you wanted to refer to a captured group of the outer gsub. Calling $1, $2, etc. would not give the right result because the last match data has changed by doing the inner gsub loop. This will be a source of bug. It is necessary to refer to captured groups via match data: string1.gsub(regex1) do |string2| m1 = $~ string2.gsub(regex2) do m2 = $~ ... # match data of t

Categories : Ruby

capture content in html comments with regex
I guess you can make use of a positive lookahead: <!-- #BeginEditable "(Title|Text|Foo)" -->(.*?)(?=<!-- #EndEditable -->) Here's a demo on rubular. Note I used the m modifier to make the dots match newlines. The dot will thus match every character until it finds <!-- #EndEditable --> ahead.

Categories : HTML

Only capture digits instead of the other text in input for a regex like below
Just change the boundaries of the second group to only include the digits. To also save the "H.B." part, add paranthesis around that part too: ^(?:(\S+)\s+)*?(\d+)\S+\s+(?:No\.\s+)?(\S+)(?:\s+\(.*?\))?$

Categories : Java

Using regex to capture text in parentesis if they exist
If you try to match line by line, you can use this regex: ^(.+?)(?: ((.+)))?$ I added the start of line anchor and end of line anchor, then put the space in the first non-capturing group, so that the title without any other details can be captured. I changed the * operator to ?, since I don't think you'll have more than one pair of brackets. Change if you think you do have more. I removed the second non capturing group as the end of line anchor will ensure it's the end of the line. Demo here.

Categories : Python

.NET Regex to back capture only the number from a matching group
I do not think this is possible - here's a question that seems to be exactly the same thing you're asking for: Regex Pattern Matching Concatenation

Categories : Dotnet

Regex to capture characters at set positions in a variable string
It seems much easier to do this without using regular expressions, but for the sake of argument, you can use this pattern: ^(dd)(dd)?(dd)?$ Or this pattern, which actually has only one capture group, which might be easier to work with depending on your code: ^(dd){1,3}$ Both patterns will match either 2, 4, or 6 digits in groups of two and nothing else. Test it out here.

Categories : Regex

Why does this regex named group capture the wrong text?
Use MatchData#[] to get specific group string: str1 = <<eos Burp FirstName: Al Bundy Ref person: Some address: loststreet 4 Some other address: loststreet 4 Zip code: eos regex1 = /FirstName:s?(?<name>[^ ]*).*Ref person:s?(?<ref_id>[^ ]*).*Some other address: (?<other>[^ ]*)/mi matched = str1.match(regex1) matched['name'] # => "Al Bundy" matched['other'] # => "loststreet 4"

Categories : Ruby

Quick capture of a specific frame
using this code as a base will help you getting a high performance. You can always play with the time in waitKey() but a 0 parameter will lead to an error. VideoCapture capture(filename); Mat frame; if( !capture.isOpened() ) throw "Error when reading steam_avi"; //namedWindow( "w", 1); for(;;) { capture >> frame; if(frame.empty()) break; waitKey(20); // waits to display frame }

Categories : Opencv

Capture string between specific characters
Take the left part &lt;TITLE&gt; and the right part &lt;/TITLE&gt; and put (.*?) in between:&lt;TITLE&gt;(.*?)&lt;/TITLE&gt; Online demo

Categories : Ruby

Accessing my capture group in regex pattern matching in Expect to a variable
The issue is that you are including line anchors ^ and $ in your regex. The string you're trying to match is clearly a multi-line string, but Tcl's default matching treats newlines just like a regular character. Another complicating factor is that Tcl considers a newline to be but expect is using as the line terminator. If you enable newline sensitive matching in the regular expression and take the carriage return into account, you may find this regular expression works: (?n)^thississasline((?:sd)+) ?$ Testing: $ expect <<END spawn sh -c {echo foo; echo "this is a line 2 4 5 6"; echo bar} exp_internal 1 expect -re {(?n)^thississasline((?:sd)+) ?$} END spawn sh -c echo foo; echo "this is a line 2 4 5 6"; echo bar Gate keeper glob pattern for '(?n)^thississasline((?:sd)+) ?

Categories : Regex

Capture specific form-items into some dictionaries
I am wondering why you are not using Strongly typed Datatype i.e. Sending Model from view in Controller. This is the most effective and recommended way. Take a look at below link, this might help you a little bit View to Controller in mvc3

Categories : C#

How do I capture a specific value from a POST ajax response?
inside your if ($(data).length === 1) statement you can add debugger; (or set a break-point) then examine the data object using chrome's developer tools. The id you're after will be something like data.objects[0].id

Categories : C#

Capture the CellEditEnding event for a specific DataGridTextColumn
In CellEditEnding event handler you can check column by header: private void OnEndEdit(object sender, DataGridCellEditEndingEventArgs e) { if (e.Column.Header.ToString() == "Notes") { Debug.WriteLine("Saving..."); } }

Categories : Wpf



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