w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Meta Regex: test if regex is only a string (no regex "wildcards")
Well, there's a quick two-step way to test for this. Instead of testing for escaped characters and wildcards in one regex, the first line of your function could remove escaped characters, then the second line would test the remaining string for wildcard-type expressions. .*(([.+?])|({[0-9]*,[0-9]*})|(*)|(+)).* will match a string that contains any *, +, {#,#}, or [] expression. In your function, return whether or not the passed string matches this expression.

Categories : C++

nose framework command line regex pattern matching doesnt work(-e,-m ,-i)
Nose is likely using Python's re.match, or something equivalent, which requires a match at the beginning of the string. _size doesn't match because the function name test_fn_size_sha doesn't start with the regex _size. Try using a regex that matches from the beginning: nosetests -w cases/ -s -v -m='w+_size'

Categories : Python

java.util.regex.PatternSyntaxException: Syntax error in regex pattern near index
+ should be escaped, cause + is used to represent one of the quantifiers it should be s.split("\+");

Categories : Java

Ignore REGEX in MVC model or Select another REGEX depending upon User input
There are a few different options for you: Create a 100% custom validation attribute that combines the Required and RegularExpression attributes to your needs. So inside that custom attribute you would do all the validation that you need and compare the value to the Country property to selectively apply the RegEx as needed. Create a different postcode attribute per country that you care about and use something like the `RequiredIfAttribute (see RequiredIf Conditional Validation Attribute) to determine which one is actually required. You can then use Javascript to show/hide the appropriate input fields.

Categories : C#

Boost regex not replacing expression that replaces correctly on regex websites
The problem come from your first (.+) which is greedy and grab all he can, probably until the last # of the subject string. You can try with this pattern: const char *scriptRegexFullNameReplace = "$1"$2"#"$3"$4"; scriptRegexFullName.assign("(\p{L}+,\d+,\d+,\d+\s+script\s+)([^#]+)#(\S+)(\s+\d+,\{)"); Notices: the escape of the curly bracket is probably uneeded, try to remove it. p{L} stand for any unicode letter but you can try replace it by [^,] if it is a problem You can replace all + by ++ for more performances (no backtracks allowed) No need to capture the sharp to replace it by itself, it is the reason why the pattern has only four capturing groups instead of using (.+?) (the dot with a lazy quantifier), it is better for performances to use a greedy quantifier with a reduced cha

Categories : C++

java regex what the heck? am I misreading the regex docs completey?
String#matches() tests this string against the entire pattern. Let's take a trip down JavaDoc lane: String#matches(String) Tells whether or not this string matches the given regular expression. An invocation of this method of the form str.matches(regex) yields exactly the same result as the expression Pattern.matches(regex, str) so let's trace it through: Pattern#matches(String regex, CharSequence input) Compiles the given regular expression and attempts to match the given input against it. An invocation of this convenience method of the form Pattern.matches(regex, input); behaves in exactly the same way as the expression Pattern.compile(regex).matcher(input).matches() One last step: Matcher#matches() Attempts to match the entire regio

Categories : Java

Hive ParseException - cannot recognize input near 'end' 'string'
The issue isn't actually a syntax error, the Hive ParseException is just caused by a reserved keyword in Hive (in this case, end). The solution: use backticks around the offending column name: CREATE EXTERNAL TABLE moveProjects (cid string, `end` string, category string) STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler' TBLPROPERTIES ("dynamodb.table.name" = "Projects", "dynamodb.column.mapping" = "cid:cid,end:end,category:category"); With the added backticks around end, the query works as expected. Reserved words in Amazon Hive (as of February 2013): IF, HAVING, WHERE, SELECT, UNIQUEJOIN, JOIN, ON, TRANSFORM, MAP, REDUCE, TABLESAMPLE, CAST, FUNCTION, EXTENDED, CASE, WHEN, THEN, ELSE, END, DATABASE, CROSS Source: This Hive ticket from the Facebook Phabricato

Categories : Hadoop

Parsing SQL statements with regex: Does adding the optional flag in a regex expression change how greedy or posessive modifiers are matched?
Parsing SQL with regex is not much different from parsing HTML with regex. In other words, it won't work. It is hopeless task, stop right now. Instead, use some SQL parser. For example, SQL::Statement::Structure for Perl or ANTLR for Java. Also, since you are creating your own database, it is worth taking a look at how other SQL implementations do it. I would recommend reading source code for PostgreSQL or MySQL and see how they implement advanced SQL parsing.

Categories : Java

Within same regex expression , performing multiple regex operations
From your description it sounds like you need to use the backreference construct Backreference Construct :MSDN There are examples in the linked page. Using this you can refer to repeated occurrences of a substring within a string.

Categories : Regex

Pass regex special characters through web form to PHP regex
I don't know better ways (don't think there are any…), but one way would be to just remove the backslash before asterisks after the preg_quote function call: $find = str_replace("\*", "*", $find);

Categories : PHP

Performing a Regex Expression on a String of which may contain Regex Metacharacters?
.NET provides the Regex.Escape method for exactly this purpose: Dim regDirs = New Func(Of String, Boolean)(Function(i) Regex.IsMatch(i, "[d]+[s]" & Regex.Escape(strName), RegexOptions.Compiled Or RegexOptions.IgnoreCase))

Categories : Regex

Regex performance issue - can anyone explain way this regex is slow
A and  means beginning and the end of the string. Therefore the regex is more limited and has less searching to do. For example if your text has newlines in it, the 2nd regex is way faster since it only searches the first new line where the 1st regex keeps searching

Categories : C#

translate Ruby regex to php/perl regex
You have a strange error in your Regexp. I think it's partially luck it's working on Rubular: (1?[[(s.-]]d{3})?[s.-]d{3}[s.-]d{4}(z[^d])?) ^ ^ Why are those brackets there two times? See here for a working version where I just removed those. Works fine with PHP now: http://www.regex101.com/r/gR6kS3 (1?[(s.-]d{3})?[s.-]d{3}[s.-]d{4}(z[^d])?)

Categories : PHP

Replace multiple regex into one regex in perl
You can do it like this: message =~ s# &lt; (?<tag>span|em|ul|ol) &gt; (.*?) &lt; / k<tag> &gt; # <$+{tag}> $2 </$+{tag}> #xg;

Categories : Regex

Java regex: need one regex to match all the formats specified
Try using a reluctant quantifier: _year:.*?s. .replaceAll("_year:.*?\s", "_year:Y ") System.out .println("utc-hour_of_year:2013-07-30T17 dsfsdgfsgf utc-week_of_year:2013-W31 dsfsdgfsdgf" .replaceAll("_year:.*?\s", "_year:Y ")); utc-hour_of_year:Y dsfsdgfsgf utc-week_of_year:Y dsfsdgfsdgf

Categories : Java

rewrite VBScript.Regex to C# Regex code
Try this: Regex re = new Regex(@"({ ?)|(""(""""|[^""]*)*"")|([^},{]+)|(, ?)|(} ?)", RegexOptions.IgnoreCase | RegexOptions.Multiline); MatchCollection matches = re.Matches(textBox1.Text); var Tree = new SimpleTree<string>(); foreach (Match m in matches) { if( m.Groups(4).Value != null ) { // do your stuff here } }

Categories : C#

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

PHP regex, how can I make my regex only return one group?
preg_match_all is returning exactly what is supposed to. The first element is the entire string that matched the regex. Every other element are the capture groups. If you just want the the capture group, then just ignore the 1st element. preg_match_all('/hello:"(.*?)"}/', 'hello:"abcdefg"},"other stuff', $arr, PREG_PATTERN_ORDER); $firstMatch = $arr[1];

Categories : PHP

(Bash) Regex variable inside another regex
The immediate problem is not a regex issue. You have your $tldlist variable inside single quotes, and single quotes prevent variable expansion. Change your second line to, e.g.: curl="$(curl -vfIk https://$hostname 2>&1 | sed 's/^* //g' | tr '[A-Z]' '[a-z]' | grep -i --color=never -E "CN=(.*).$tldlist")" so as to allow $tldlist to expand.

Categories : Regex

Regex doesnt replace ' { ' with '{'
The "{" starts repetition like "{1,3}" and is reserved so you should escape it. $board_code_dup.html( board_code_dup_html.replace(/{/g, "<span>{</span>") );

Categories : Regex

MVC 4 View doesnt recognize model
I don't understand what the parentheses are doing in the model declaration. The syntax for @model should be: @model Your.Namespace.ClassName The in your code you use Model, not model.

Categories : Asp Net Mvc

How to use two types of regex in single regex?
Yes..you can use |(OR) between those two regex.. [\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}|\d+ ^

Categories : Java

How to convert this PHP Regex to Javascript Regex?
In JS, you can do it simple do a .test() with Regex(no need to change the expression). var yourRegEx=/^(([^,]+,){4}[^,]+ ){3}$/; if(yourRegEx.test($all_questions) { // replace $all_questions with your // js variable }

Categories : Javascript

Regex for Regex validation decimal[19,3]
Simplification: The d doesn't have to be in []. Use [] only when you want to check whether a character is one of multiple characters or character classes. . doesn't need to be escaped inside [] - [.] appears to just allow ., but allowing to appear in the string in the place of the . may be a language dependent possibility (?). Or you can just take it out of the [] and keep it escaped. So we get to: d{1,16}|d{1,16}.d{1,3} (which can be shortened using the optional / "once or not at all" quantifier (?)      to d{1,16}(.d{1,3})?) Corrections: You probably want to make the second d{1,16} optional, or equivalently simply make it d{0,16}, so something like .1 is allowed: d{1,16}|d{0,16}.d{1,3} If something like 1. should also be allowed, you'll need to add an

Categories : Regex

Javascript regex to match a regex
A regular expression to match a regular expression is //((?![*+?])(?:[^ [/\]|\.|[(?:[^ ]\]|\.)*])+)/((?:g(?:im?|mi?)?|i(?:gm?|mg?)?|m(?:gi?|ig?)?)?)/ To break it down, / matches a literal / (?![*+?]) is necessary because /* starts a comment, not a regular expression. [^ [/\] matches any non-escape sequence character and non-start of character group [...] matches a character group which can contain an un-escaped /. \. matches a prefix of an escape sequence + is necessary because // is a line comment, not a regular expression. (?:g...)? matches any combination of non-repeating regular expression flags. So ugly. This doesn't attempt to pair parentheses, or check that repetition modifiers are not applied to themselves, but filters out most of the other ways that regular expressions

Categories : Javascript

Multiple matches of regex within other regex
You can use look-around. (?<=one)(bla)*(?=one) Positive look-behind ((?<=...)) checks that the previous characters match some pattern. Positive look-ahead ((?=...)) checks that the next characters match some pattern. Look-around is not included in the matched string. Test. Or you can simply put the part you want to extract in brackets and extract group 1. (the ?: is to make (bla) a non-capturing group, it doesn't change the match, just what gets captured). one((?:bla)*)one Test.

Categories : Regex

regex multiple replaces in one go using c++ regex
Description Regex: ^(.*?)TableOne[.]@ColumnTwo,s+(.*?)[@](.*?)$ Replace with: 123 Example This is C# example is added to show how the regex works. using System; using System.Text.RegularExpressions; namespace myapp { class Class1 { static void Main(string[] args) { String sourcestring = "SELECT TableOne.ColumnOne, TableOne.@ColumnTwo, TableOne.ColumnThree FROM TableOne WHERE TableOne.@ColumnTwo ='abc'"; String matchpattern = @"^(.*?)TableOne[.]@ColumnTwo,s+(.*?)[@](.*?)$"; String replacementpattern = @"123"; Console.WriteLine(Regex.Replace(sourcestring,matchpattern,replacementpattern,RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline)); } } } $sourcestring after replacement: SELECT Table

Categories : C++

Check the end of a string for valid regex and return the string trimmed of the regex-
You should simply replace: str = 'testfoostringfoo'; var regex = /foo$/; str = str.replace(regex, ''); return str; I removed the if, replace does not affect the string when regex is not found. Keep in mind that match returns an array of matches (['foo']), so the comparison to true fails either way: the condition in if(str.match(regex) == true) is always false. You're looking for if(str.match(regex)) or if(regex.test(str)). Note that trim is somewhat new in JavaScript, and it doesn't take parameters, it just removes whitespaces.

Categories : Javascript

Java UIMA: Regex Variable inside Regex Variable?
According to the docs, The regex variable name can contain any of the following characters [a-zA-Z_0-9]. Other characters are not allowed. If that's the only restriction, 123 would be a valid name, which you would refer to as value="v{123}". How is the parser supposed to know you mean the rule named "123" and not one hundred and twenty-three vertical tab characters? In most languages (including XML), names can't start with digits. If that were the case here, it would be possible to embed variable names in variable definitions, because v{month} or v{_123} is guaranteed to be invalid in a Java regex. (Other regex flavors are more liberal; they would interpret the braces as literal brace characters because {month} and {_123} can't be interpreted as range expressions.) The only wa

Categories : Regex

Convert JS Regex to PHP Regex
You can do it like this: $messagetext = preg_replace('~^h*+#Kw++~m', '<a class="myHashtag" ' .'href="http://search.twitter.com/search?q=%23$0" target="_blank">#$0</a>', $messagetext); pattern detail: ^ # line's begining h*+ # horizontal space (ie space or tab), zero or more times (possessive) # # literal # K # forgets all the begining! w++ # [a-zA-Z0-9_] one or more times (possessive) Delimiters are ~ but you can choose other characters. I use the multiline mode (m modifier), thus ^ stands for line's begining. (possessive) indicates to the regex engine that it don't need to backtrack by adding a + after a quantifier. The subpattern becomes then more efficient.

Categories : PHP

Convert JavaScript Regex String to PHP Regex String
Regular expressions are not language specific. They are applicable in most coding languages and used the same way -- the only difference is how they are applied. For PHP, use methods such as preg_match or preg_replace. For more information on Regular Expressions, go here. If you go to Languages and Libraries, you can see all the coding languages that support Regular Expressions. Some may require libraries or packages, but in general the way you write regular expressions is fairly universal. EDIT: I stand corrected as there are some very slight variations between different coding languages for how they handle Regex. You can find out how to make Regular Expressions for PHP here: http://www.php.net/manual/en/regexp.introduction.php You can also get more information on some of the subtle d

Categories : PHP

Regex to match single new line. Regex to match double new line
To match exactly N repetitions of the same character you need lookaheads and lookbehinds (see Match exactly N repetitions of the same character). Since javascript doesn't support the latter, a pure regexp solution seems to be impossible. You'll have to use a helper function, for example: > x = "...a...aa...aaa...aaaa...a...aa" "...a...aa...aaa...aaaa...a...aa" > x.replace(/a+/g, function($0) { return $0.length == 2 ? '@@' : $0; }) "...a...@@...aaa...aaaa...a...@@"

Categories : Javascript

Hadoop Hive - best use cases to create a custom Hive Input and Output formats?
one of the various file formats used for Hive are RCFile, Parquet and ORC file formats. These file formats are columnar file format. This gives an advantage that when you reading large tables you don't have to read and process all the data. Most of the aggregation queries refer to only few columns rather than all of them. This speeds up your processing hugely. Other application could be storing , reading and processing your custom input format, where data might be stored differently than csv structure. These might be binary files or any other structure. You will have to follow the documentation to create input formats. For details you can follow the link: Custom InputFormat with Hive

Categories : Hadoop

Tables created by oozie hive action cannot be found from hive client but can find them in HDFS
Inside your oozie hive action you need to tell oozie where your hive metastore is. Means you need to pass your hive-site.xml as argument. Also you need to configure external metastore for hive for it to work. The default derby database configuration will not work for you. So in simple steps Create hive settings with external database , say mysql Pass that hive-site.xml to oozie action See here for details http://oozie.apache.org/docs/3.3.1/DG_HiveActionExtension.html Thanks

Categories : Hadoop

Access Hive Metastore server information from Hive Shell
You could use the SET command through the Hive CLI. But it prints all the variables in the namespaces hivevar, hiveconf, system, and env. So, you could use it with grep to print just the properties you need. For example if you want to see what is the value of mapred.reduce.tasks which you set in hive-site.xml then you could do this : bin/hive -S -e "set" | grep mapred.reduce.tasks Or to get the metastore related info you could do this : bin/hive -S -e "set" | grep metastore I don't know if this what you were expecting, but it does the trick for me. Hope this helps you too.

Categories : Mysql

hive-hwi-0.9.0.war is missing in Hive home directory
dino.keco was right! Standart Hive distribution has hive-hwi-0.9.0.war in ${HIVE_HOME}/lib I just downloaded Hive distribution again and copied hive-hwi-0.9.0.war to my local Hive installation.

Categories : Hadoop

Error in Hive : Underlying error: org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException: One or more arguments are expected
Does not look like a valid "Hive" query to me. Remember hive's query language is pretty limited compared to SQL. For example "IN" is not supported. Another exmaple RANK() OVER (...) - that's not supported either. In other words attempting to use RDBMS SQL directly in Hive mostly not work.

Categories : SQL

where do I put my regex
Here's one way to use your regex to only get the two matching lines: $('#test h4 a').each(function () { var $link = $(this), text = $link.text(); if (/^.*(Gold|Silver).*$/.test(text)) $link.after(text); $link.remove(); }); That is, in your .each() loop you can remove the link every time, but before that only add the text in if the item matches. Demo: http://jsfiddle.net/nFnEF/1/ To remove the "Metal Price..." part, you can do a .replace() with a different regex that captures the two parts you want to keep: var re = /^(Gold|Silver)[^-]+-s?([d.]+)$/; $('#test h4 a').each(function () { var $link = $(this), text = $link.text(); if (re.test(text))

Categories : Jquery

Regex in std c++
There is nothing wrong with the regular expression, but you need to search for it repeatedly. And than you don't really need the parenthesis anyway. The std::regex_search finds one occurence of the pattern. That's the {aaa}. The std::wsmatch is just that. It has 3 submatches. The whole string, the content of the outer parenthesis (which is the whole string again) and the content of the inner parenthesis. That's what you are seeing. You have to call regex_search again on the rest of the string to get the next match: std::wstring::const_iterator begin = chatMessage.begin(), end = chatMessage.end(); while (std::regex_search(begin, end, m, e)) { // ... begin = m.end(); }

Categories : C++

Regex: Getting a certain value from a URL
Not knowing how you are going to go about using regex to pull the number out, or what code is surrounding it, d+ will match to one or more numbers. See here for a reference page on basic regex syntax. Edit: Because you have other numbers in there, I'd use either A) a look behind (as long as you aren't doing the regex in JavaScript, as it doesn't support look behinds) or B) by defining the minimum number of characters you want to make. A) d+(?<=/d+) - match one or more numbers, look behind to check that there is a / preceding the numbers B) d{5,} - match any numbers, at least 5 of them, with no upper limit on how many it can match

Categories : Regex



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