w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Regex look for all quotes not preceded by a comma
The regex you are asking for would be (?<!,)" Alternatively, if you're not averse to matching more than you need you can use (^|[^,])" which would match the preceding non-comma as well as the double-quote, but support for it should be more widespread (excluding findstr). However, for parsing CSV files you should use a proper parser as any regex-based solution (at least those I have seen so far for this task) is error-prone unreadable slow

Categories : Regex

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

Skip text between quotes in Regex
With all of the possible cases involving mixed sets of quotes, a regex may not be your best option here. What you could do instead (after using your current regex to filter for everything but quotes), is count the number of quotes before and after the occurrence of textToFind. If both counts are odd, then you have quotes around your keyword and should scrap the line. If both are even, you've got matched quotes elsewhere (or no quotes at all), and should keep the line. Then repeat the process for double quotes. You could do all this only walking through the string once. Edit to address the update that you're searching through code: There are some additional considerations to take into account. Escaped quotes (skip over the character after an escape character, and it won't be counted). Co

Categories : C#

regex pattern for http url without quotes in vb.net
If you expect to have multiple URL's in your string then you need to define what will be their separator, for example, a blank space some text http://abc http://123 nonurltext or like it seems to be the case based on your regex some text(http://abc) some other text (http://123) some more text, once you have this delimeter, then you can use it to tell regex how to zero in on the string you really want. The following will get http://... if it's enclosed in parenthesis, like (http://www.yahoo.com) ignoring everything else Regex.Matches(test, "(?<=()http://.+?(?=))", RegexOptions.IgnoreCase) You should be able to just change this to suit your needs, for example if your delimeter were blank spaces, then just replace ( and ) with s (means blank space)

Categories : Regex

RegEx exclude matches between quotes
How about finding: ([^=]+)=("[^"]*"|[^,]+)(?:,s*)? Then extract group 1 (the key) and 2 (the value(s)). [^=]+ - one or more characters that aren't =. "[^"]*" - any characters between quotes. [^,]+ - one or more characters that aren't ,. (?:,s*)? - consume the , with any spaces after it (the only difference between (...) and (?:...) is that the latter doesn't assign a group to it). This won't work if brackets can be nested. Test.

Categories : Regex

Why is regex failing on already-escaped quotes?
You can avoid all the escaping by choosing a different regex delimiter and using single quotes around your string like this: $re='~Built upon the <a href="[^>]+banshee-php.org/">[a-z]+</a>(?:v([d.]+))?\;version:1~U';

Categories : PHP

Get all items inside quotes in Cucumber Step Definition
This seems like a good place to use the #And alias. Given I attach dog.png And I attach cat.png And I attach alphabet.doc ... Alternatively you can use data tables for easy multiline arguments

Categories : Ruby

Regex to remove doubled double quotes from CSV
I think you are overthinking the problem, why don't replace data? l = list() with open('foo.txt') as f: for line in f: l.append(line.replace('""','"').replace('"{','{').replace('}"','}')) s = ''.join(l) print s # or save it to file It generates: {"first_name":"John","last_name":"Smith","age":30} {"first_name":"Tim","last_name":"Johnson","age":34} Use a list to store intermediate lines and then invoke .join for improving performance as explained in Good way to append to a string

Categories : Python

regex to strip all comments from php code except between quotes
I'm not sure if you can do that with only Regex. However, this might help you: Regex match semicolon but not in comments or quotes.

Categories : C#

javascript regex allow multiple words with quotes
Referring to thg435's comment: If you try to parse invalid json a SyntaxError is thrown. See the docs: JSON.parse parses a string as JSON and returns the parsed value. ... If the string to parse is not valid JSON, a SyntaxError exception is thrown. Sample code: try { var json = JSON.parse('[{"latitude":33.851871,"longitude":-84.364336}]'); if (json.length > 3) throw new Error("Too many coordinates"); _.each(json, function(coordinate) { if (!_.has(coordinate, 'latitude') || !_.has(coordinate, 'longitude')) throw new Error("Invalid coordinate pair found"); }); } catch (e) { // handle your invalid json and return to stop further execution console.error(e); return; } console.info('ok'); This approach uses underscorejs See for a worki

Categories : Javascript

Replace part of string between quotes in php regex
Description I would attack this problem by first splitting the string into groups of either quoted or not quoted strings. Then iterating through the matches and if Capture Group 1 is populated, then that string is quoted so just do a simple replace on replace Capture Group 0. If Capture group 1 is not populated then skip to the next match. On each iteration, you'd want to simply build up a new string. Since splitting the string is the difficult part, I'd use this regex: ("[^"]*")|[^"]* Example Sample Text "mission podcast" modcast A B C "D E F" Code PHP Code Example: <?php $sourcestring="your source string"; preg_match_all('/("[^"]*")|[^"]*/i',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?> Capture Groups $matches Array: ( [0] => Array

Categories : PHP

Regex to ignore unwanted matched quotes
may this do the trick: #!/usr/bin/env python import re string = r"""@="" @="0" @="=" @="@" @="k="v"" @=dword:00000000 @=hex:00 "k"="" "k"="=" "k"="@" "k"="k="v"" "k"="v" "k"=dword:00000000 "k"=hex:00 "k="v""="" "k="v""="=" "k="v""="@" "k="v""="k="v"" "k="v""="v" "k="v""=dword:00000000 "k="v""=hex:00 """ regex = re.compile(r'("?)(.*)1=(["hd].+)') results = regex.findall(string) for _, key, value in results: print '{} => {}'.format(key, value) it gives the result below: @ => "" @ => "0" @ => "=" @ => "@" @ => "k="v"" @ => dword:00000000 @ => hex:00 k => "" k => "=" k => "@" k => "k="v"" k => "v" k => dword:00000000 k => hex:00 k="v" => "" k="v" => "=" k="v" => "@" k="v" => "k="v"" k="v" => "v" k="v" => dword:00000000 k="

Categories : Python

Javascript regex for single, double and no quotes
"width='200', width="200", width=200".replace(/(width=)(?:".*?"|'.*?'|S*)/g, '$1"555"') // => width="555", width="555", width="555" But yeah, this is not a job for regexp.

Categories : Javascript

Bash regex to strip quotes from array element
Just change that assignment to vol_id_array+=( "${i//"}" ) This parameter expansion will cause $i to be expanded without any quotes in it as it's added to the array.

Categories : Regex

Regex to select semicolons that are not enclosed in double quotes
Regular expressions are probably not the right tool for this. If possible you should use a CSV library, specify ; as the delimiter and " as the quote character, this should give you the exact fields you are looking for. That being said here is one approach that works by ensuring that there are an even number of quotation marks between the ; we are considering the split at and the end of the string. ;(?=(([^"]*"){2})*[^"]*$) Example: http://www.rubular.com/r/RyLQyR8F19 This will break down if you can have escaped quotation marks within a string, for example a;"foo"bar";c. Here is a much cleaner example using Python's csv module: import csv, StringIO reader = csv.reader(StringIO.StringIO('a;b;"aaa;;;bccc";deef'), delimiter=';', quotechar='"') for row in reader:

Categories : Regex

RegEx - Finding Text Between Quotes and Replacing Between Parentheses
you can use notepad++ macro instead of regex. place your crusor on your second line, press home then click menu macro > start recording, then do the following steps : ctrl+right_arrow(until your number, three time maybe) ctrl+shift+right_arrow ctrl+c(copy) up_arrow home ctrl+right_arrow(until your number, three time maybe) ctrl+shift+right_arrow ctrl+v(paste) then stop recording, and pres run macro multiple times > until the end of file > run

Categories : Regex

I need a regex or method to remove sequential quotes from a string
You can Split by " first then Join them together: var result = string.Format(""{0}"", string.Join("", x.Split('"'))); For example, your input: ""I am in" a quote"" Using Split with ", you will have a list of string which does not contains " anymore. Then when you use Join with "", it means you joins them together again by empty string instead of ". The first result does not have " at first and last, use string.Format to add " to first and last to get the final result. Another simpler approach which uses Replace and PadLeft and PadRight string output = input.Replace(""", string.Empty) .PadLeft(1, '"') .PadRight(1, '"');

Categories : C#

Javascript regex, getting error when removing all single quotes except for those that precede an s
(?<![a-z]) is the problem, because lookbehind doesn't exist in javascript. If you want make some test for regex in javascript, use an online tool for javascript like regexpal. I don't know what you are trying to do but you can try this code: return str.replace(/%2[37]|(^|[^a-z])'|'(?!s)|--|#/gi, "$1-restricted-"); I have replaced the negative lookbehind (?<![a-z]) (ie: not preceded by a letter) by a capturing group (^|[^a-z]) (ie: begining of the string OR a character that is not a letter). Since it is not a simple check like a lookaround but a match, the replace will delete this "non-letter", then I put a reference in the replacement pattern to this first capturing group ($1) to replace it by itself.

Categories : Javascript

Regex: How to grab strings within quotes, commas, spaces, and new line?
You can simply split, trim and remove the quotes: var list = str.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Trim().Replace(""", ""));

Categories : C#

regex returning true even if comma is not enclosed in double quotes
Because you are creating a character range here : /^\"[a-zA-Z0-9!#$%&\'*+-/=?^_`{|}~;,:<>()@[]]*\"$/ ^^^^^ This means all characters from + to /, this includes also the ,. INside a character class, you don't need to escape the normal regex special characters, but there is another one, that get a special meaning the -. So the correct character class would be /^\"[a-zA-Z0-9!#$%&\'*+-/=?^_`{|}~;,:<>()@[]]*\"$/ The alternative would be to put the - at the start or the end of the character class, in that cases it would not create a range and does not need escaping.

Categories : Javascript

How to find certain text between quotes
Don't try to parse HTML with a regex. Instead, use an HTML parser. Something like Nokogiri http://nokogiri.org/ require 'nokogiri' doc = Nokogiri::HTML.parse '<a href="http://www.flickr.com/photos/user/9049969465/" title="Wiggle Wiggle by Anonymous, on Flickr"><img src="https://farm3.staticflickr.com/2864/92917419471_248187_c.jpg" width="800" height="526" alt="Wiggle Wiggle"></a>' doc.css('a').each do |link| puts link.attr(:href) end

Categories : Ruby

Returning java regex (words, spaces, special characters, double quotes)
First, you'll need to separate the word-matching code from the string-literal-matching code. For word matching, use: w+ Next there's whitespace. s+ To match strings as one token, you need to allow more characters than just w. That only allows alphanumeric characters and _, which means whitespace and symbols are not. You also need to move the starting and ending quotes outside of the square brackets. And don't forget backslashes to escape characters. You want to allow " inside of strings. "(\.|[^"])+" Finally, there are the symbols. You could list all the symbols, or you could just treat any non-word, non-whitespace, non-quote character as a symbol. I recommend the latter so you don't choke on other symbols like @ or |. So for symbols: [^sw"] Putting the pieces together, we get

Categories : Java

Creating a dataset variable from a macro variable containing both quotes, double quotes and mismatched quotes
The short answer is that you can use SYMGET here: data _null_; x=symget("problem"); put x=; run; If that is not an option for some reason, provide some more information as to the context. I'll also see if I can point Toby (the SAS-L macro quoting guru) or some of the other folks there here, to see if they have any suggestions for handling this without SYMGET. From SAS-L, FriedEgg (Matt) posted the following additional solution: resolve=resolve('%superq(problem)'); He also notes that you can mask it on the way in, if you have control over that: data _null_; input x $ 1-50 ; call symput('problem',quote(x)); cards4; 'this' "is '' my "string"" from 'hell! ;;;; run; data _null_; x=&problem; put x=; run;

Categories : Sas

Surrounding results of a Find command with quotes
The backtick at the end of your find command indicates that you are redirecting the command output to a variable. As commented by hex2mgl you are removing the newlines with tr. Even if you weren't piping the results to tr, it's possible that your variable wouldn't show newlines unless quoted. For example, foo=$(find . -type f -mtime -100 -daystart -printf '"%f" ') would store the results of find with pathnames quoted in the variable foo. Doing echo ${foo} would not display newlines, while echo "${foo}" would.

Categories : Linux

Escape sequences vs predefined character classes (aka special regex characters) when encapsulated by double quotes
Java, Perl, and Python all use C-style backslashes for escapes. Regex also uses C-style backslashes for escapes. This leads to problems in all three languages—and, in fact, for many, many other languages. For example, all three languages will convert '\' into a single backslash, ' ' into a newline, etc., before they can get to the regex compiler. The only difference is that in Python, unknown escape sequences like 's' resolve to themselves, while in Java and Perl they resolve to just 's'. So, in Python, while you need '\ ', you don't need '\s', while in Java and Perl, you need to escape the backslashes for both. And there are languages that make the third choice, treating unknown escape sequences as errors. So, if you have the list of known escapes memorized, you can sometimes get

Categories : Java

Javascript regular expression to find double quotes between certain characters
Given Stack Overflow's "we don't do your homework" principles, I don't think I'm going to work through the whole solution, but I can give you some pointers in half-finished code. var xySearch = /this regex should find any text between XXX...YYY/g; // note the g at the end! That's important var result; var doubleQuoteIndices = []; // note the single-equals. I avoid them when possible inside a "condition" statement, // but here it sort of makes sense. while (result = xySearch.exec(str)) { var block = result[0]; // inside of the block, find the index in str of each double-quote, and add it // to doubleQuoteIndices. You will likely need result.lastIndex for the absolute position. } // loop backwards through str (so that left-side replacements don't change right-side indexes) // to rep

Categories : Javascript

How to find with lookahead in Visual studio 2012 Regex Find and Replace
You need to add a (?s), which enables multiline matching, and also escape the period in using Example.Foo. The regex should be something along the lines of: (?s)using Example.Foo;(?=.*BaseClass<SomeClass>)

Categories : Regex

Validate string using Regex in C# failed to validate backslash or double-quotes
You need to escape a " and a in a string in C#: Regex.Replace("Slash: \ Quote: " ", @"[^0-9a-zA-Z]+", "-"); Read more about escaping characters.

Categories : C#

Batch converting straight quotes to smart quotes from MySQL database
I don't know how to enter the smart quotes in Sublime Text 2, but I tested the following regex (in Sublime Text 2 itself) for the single quote case using [] as the replacement characters: Find what: ((?:[^<'>]*|<.*?>)*)'(.*?)' Replace with: $1[$2] Hopefully this will help. Here is rubular for it, showing matches.

Categories : Regex

SQL Server Management Studio replacing single quotes with double quotes when modifying stored procedure
I believe you are getting dynamic SQL from the scripting options because you have this option selected: Tools > Options > SQL Server Object Explorer > Scripting > Check for object existence When this setting is enabled, the script is generated like this: IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = ...) BEGIN EXEC dbo.sp_executesql @statement = N'ALTER PROCEDURE...' END Disable this option, and it should be correct when you use right-click > Modify or right-click > Script stored procedure as > ALTER to >.

Categories : Sql Server

Vim: Put newlines around '{' and '}' but not around those inside strings with single quotes or double quotes
One suggestion perhaps, without posting vimscript (though I cannot think of a regex that will do this in one pass) is to decide upon some marker scheme (I prefer 3 hashes) and do it in stages. I will be back later with the correct regex (the commands I'm familiar with are not working so well on my windows gvim install) Step 1: With a regex that searches for anything of the form .*["||'].*{.*}.*["||'] (i.e. braces inside quotes) prepend matching lines with your marker Step 2: Now with a regex search for any lines that match something like: ^[^###]+.*{.*} (i.e. anything with braces and the line not beginning with markers) and put in your returns Step 3: remove the markers

Categories : PHP

Double quotes inside single quotes in oracle statement
I don't think the problem comes from your column name, as shown in this working example: SQL> CREATE TABLE trytable (ID VARCHAR2(10), "DEFAULT" NUMBER); Table created SQL> BEGIN 2 EXECUTE IMMEDIATE 3 'INSERT INTO trytable (ID, "DEFAULT") VALUES (''monkey1'', 0)'; 4 END; 5 / PL/SQL procedure successfully completed Technically, you can have a table column name named DEFAULT, even if it's generally a bad idea that will lead to confusion. You will only be able to interact with it through the double-quote " syntax because DEFAULT is a reserved word. If you specify double quotes around identifiers, Oracle will treat them as case-sensitive, so you have to make sure that they match the table specs. In your case, it would help to have the specific error message.

Categories : Oracle

Why do I have to escape double quotes in my string surrounded by single quotes?
Looks like you are missing semicolon ; at the end of your variable assignment. It should be: $weapon_secondary = '<select name="weapon" class="dropdown"> <option>Option 1</option> <option>Option 2</option> </select>'; As an alternative you can use heredoc to declare a variable and avoid this quoting exercise: $weapon_secondary <<< EOF <select name="weapon" class="dropdown"> <option>Option 1</option> <option>Option 2</option> </select> EOF;

Categories : PHP

Single quotes, double quotes and passwords containing $ in Windows and Unix
You can dump from within a pdo PHP script : <?php $dumpSettings = array( 'include-tables' => array('table1', 'table2'), 'exclude-tables' => array('table3', 'table4'), 'compress' => CompressMethod::GZIP, /* CompressMethod::[GZIP, BZIP2, NONE] */ 'no-data' => false, /* http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-data */ 'add-drop-table' => false, /* http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_add-drop-table */ 'single-transaction' => true, /* http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_single-transaction */ 'lock-tables' => false, /* http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_lock-tables */ 'add-l

Categories : Windows

Regex - Find all groups where you can find a given number
You can try this regex [^:]*(?<=[-:])2(?=[-:])[^:]* [^:] means match any character except : [^:]* would match 0 to many characters except : 2(?=[-:]) would match 2 only if it is followed by - or : (?<=[-:])2 would match 2 only it is preceded by - or : OR [^:]*2[^:]*

Categories : Regex

PHP Replace attribute single quotes with double quotes
I realized that PHP's DOMDocument class does this automatically... libxml_use_internal_errors(true); //use this to prevent warning messages from displaying because of the bad HTML $html = new DOMDocument();//'1.0','UTF-8' $html->xmlStandalone = false; $html->loadHTML($b); $b = $html->saveXML();

Categories : PHP

Replacing dumb quotes for smart quotes with preg_replace
$singlequotesPattern = "/'(.*?)'/"; Add a ? to make the * quantifier non-greedy. A greedy quantifier finds the longest match possible. A non-greedy one finds the shortest. Greedy: Jane said 'How do we do this?' 'I don’t know' replied Sam. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Non-greedy: Jane said 'How do we do this?' 'I don’t know' replied Sam. ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^

Categories : PHP

Best Way to escaping single quotes and double quotes in a string
you should use fn:escapeXml() because It escapes quotes and also other characters that could be interpreted as XML markup. . It also helps in prevention of XSS attack in JSP.

Categories : String

Apply regex to all items of a QStandardItemModel
If you only want to browse your model and apply a regular expression, you can use QAbstractItemModel::rowCount() and QAbstractItemModel::columnCount() and two loops to get each item in your model with QAbstractItemModel::item(): for ( int col = 0; col < model.columnCount(); ++col ) { for( int row = 0; row < model.rowCount(); ++row ) { item = model.item( row, col ); doSomething( item->text() ); } } If you want to filter your model to display only the items that match your regexp, you should use a QSortFilterModel. Edit for small syntaxic typo and indent.

Categories : Qt

I can't get the results I'm looking for with regex and nested items
PHP supports recursive syntax (like (?R)), so you can use this regex: [((?:[^[]]+|(?R))+)] regex101 demo The results are: if:name <strong>[name]</strong>, id (?R) is a repeat of the whole regex, hence 'recursive'. The other characters should be easy enough to understand, if not, regex101 provides quite a comprehensive description of the components of the regex :)

Categories : PHP



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