So for example:
function(input){
var testVar = input;
string = ...
string.replace(/ReGeX + testVar + ReGeX/, "replacement")
}
But this is of course not working :)
Is there any way to do this?
...
I'm struggling to get a regexp (in Ruby) that will provide the following
"one, two" -> "one"
"one, two, three" -> "one"
"one two three" -> "one two three"
I want to match any characters up until the first comma in a string. If there are no commas I want the entire string to be matched. My best effort so far is
/.*(?=,)?/
This produ...
I'm trying to check a textarea to make sure it contains text phrase(s).
This is what I have so far but it's not working:
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please i...
using regular expression for searching phrase in the file
So...
Task:
I have some phrase. the phrase contains 2 words. Phrase is devided into two words with next symbols:
[\s]*
How can i find the phrase using regular expression?
This code doesn't work on a file:
// file: Main.java
class
Main {
}
program
...
I want to write a regular expression which matches anything between () (()) (()()) ((())) ()()().....
...
I want to replace all font-size-parameters in a html document (css attributes).
I'm using .net with c#.
I guess it could be done with some regular expression.
Am I forgetting some other ways to set the font size?
Example:
<html>
<head>
<style type="text/css">
.t {
font-size: large;
...
Hi,
I'm having problems with removing duplicate lines in a file, and replacing them a with a non-duplicate line. Ideally, I would just like to replace it with a continuous sequence, so that the duplicate lines could be separated.
I was considering sed with some kind of wildcard (*):
sed -e "s/text_pattern/text_pattern*/g" my_file.txt
...
I currently have this regular expression to split strings by all whitespace, unless it's in a quoted segment:
keywords = 'pop rock "hard rock"';
keywords = keywords.match(/\w+|"[^"]+"/g);
console.log(keywords); // [pop, rock, "hard rock"]
However, I also want it to be possible to have quotes in keywords, like this:
keywords = 'pop ro...
Hi
I am going through a large website (1600+ pages) to make it pass Priority 1 W3C WAI. As a result, things like image tags need to have alt attributes.
What would be the regular expression for finding img tags without alt attributes? If possible, with a wee explanation so I can use to find other issues.
I am in an office with Visua...
Hello,
What's a quick way for matching the following in a multiline string using preg_match?
id=334534534
id= is constant, the digits are what I need to extract.
...
Hi All,
I am using IIS7 URL rewriting with my website which is written in ASP.NET. I am not sure the best way to deal with / in the rewritten URL because currently, when one is present it breaks the parameters because the engine thinks it needs to split it at the wrong place. For example, a url like:
www.test.com/myscript.aspx?code=dot...
I had requirement where user should add only specific type of links
as part of the attachments. For example, if user wants to upload
file of type pdf, the url should end with .pdf similarly for document
it should be .doc
To check this scenario I had written JUnit test as below
String url="ar.jpg";
String pm="(.*?)\\.(jpg|jpeg|png|gif)$...
I have special strings like name1="value1" name2='value2'. Values can contain whitespaces and are delimited by either single quotes or double quotes. Names never contain whitespaces. name/value pairs are separated by whitespaces.
I want to parse them into a list of name-value pairs like this
string.magic_split() => { "name1"=>"value1",...
Hello,
I'm parsing an xml file, that has nodes with text like this:
<img src="someUrl1"> American Dollar 1USD | 2,8567 | sometext
<img src="someUrl2"> Euro 1EUR | 3,9446 | sometext
<img src="someUrl3"> Japanese Jen 100JPY | 3,4885 | sometext
What I want to get is values like this:
American Dollar, USD, 2,8576
Euro, EUR, 3,9446
Japan...
I have an html that has a lot of the following:
<TD CLASS="broke"> - WF-1234567 - </TD>
<TD CLASS="broke"> - WF-1111111 - </TD>
<TD CLASS="broke"> - WF-7654321 - </TD>
I want to make a javascript bookmarklet to replace all the 7-digit numbers with a hyperlink.
How does one do this?
My attempt with many things wrong....
javascript...
How can I match characters (with the intention of removing them) from outside the unicode Basic Multilingual Plane in java?
...
Hi, I'm trying to perform a simple replace(); method in JavaScript where I'd like to remove every class from an HTML element except a specific one, how can I do it?
I tried this without success:
<div id="my_div" class="hello letsgo baby is_checked cool">Gordon Freeman</div>
<script>
$(document).ready(function () {
alert ($(#my_div...
I'm looking for a regular expression that will accurately identify any PHP call time pass by references in source code in order to aid migration to PHP 5.3.
Currently, I have [^=&]\s*&\s*\$, but this doesn't filter out assignment cases ($var = &$othervar;).
This regexp should be compatible with eclipse (sorry, not sure what flavor of...
I'm sure there is a simple solution, but I just seem to be missing it.
I need a regex to do the following:
asdf.txt;qwer should match asdf.txt
"as;df.txt";qwer should match as;df.txt
As you can see, I need to match up to the semi-colon, but if quotes exist(when there is a semi-colon in the value), I need to match inside the quotes. S...
Hi people.
I would need a regular expression that escapes or captures (if not already escaped) ALL the double quote characters INSIDE a single quoted string and then convert the opening single quotes to double quotes!
We are refactoring files that have a lot (and i mean a lot!) of single quoted strings in either PHP and also JS files. ...