We have a site I'll call example.com. Most of the time you see http://www.example.com and sometimes we redirect you to https://www.example.com.
We want to redirect anyone going to http://example.com or http://*.example.com to http://www.example.com, and the same for https. (It's mainly to avoid the alert you get if you go to https://exa...
Consider a JavaScript method that needs to check whether a given string is in all uppercase letters. The input strings are people's names.
The current algorithm is to check for any lowercase letters.
var check1 = "Jack Spratt";
var check2 = "BARBARA FOO-BAR";
var check3 = "JASON D'WIDGET";
var isUpper1 = HasLowercaseCharacter...
I have a log file that looks like the following:
2010-05-12 12:23:45 Some sort of log entry
2010-05-12 01:45:12 Request XML: <RootTag>
<Element>Value</Element>
<Element>Another Value</Element>
</RootTag>
2010-05-12 01:45:32 Response XML: <ResponseRoot>
<Element>Value</Element>
</ResponseRoot>
2010-05-12 01:45:49 Another log entry
What...
I am using ruby 1.8.7. I am not using rails.
How do I find all the links which are not already in anchor tag.
s = %Q{ <a href='www.a.com'><b>www.a.com</b></a> www.b.com <div>www.c.com</div> }
The output of above string should be
www.b.com
www.c.com
I know "b" tag before www.a.com complicates the case but that's what I have to wor...
Hi,
Could anyone please tell me the reason of getting an output as: ab for the following RegExp code using Relcutant quantifier?
Pattern p = Pattern.compile("abc*?");
Matcher m = p.matcher("abcfoo");
while(m.find())
System.out.println(m.group()); // ab
and getting empty indices for the following code?
Pattern p = Patt...
I know that:
preg_replace('<br\s*\/?>', '', $string);
will remove all br tags from $string...
How can we remove all <br><br/><br /> tags only if they are in the very beginning of $string? ($string in my case is html code with various tags...)
...
I have an input like this test1.test2.part01 which I want to strip away to test1.test2. The only thing i know is that it will end with partxx and probably a dot before the partxx. However, it will not always be a apart. Another example of input might be testas1.tlp2.asd3.part10 which ofcourse should be stripped to testas1.tlp2.asd3.
I'...
I'm trying to write some Elisp code to format a bunch of legacy files.
The idea is that if a file contains a section like "<meta name=\"keywords\" content=\"\\(.*?\\)\" />", then I want to insert a section that contains existing keywords. If that section is not found, I want to insert my own default keywords into the same section.
I've...
I love ack.
I need to search for 'foo' in all the files except the test files.
ack has option -G to specify regex. However I am not sure how do I write regex for the condition that look for all files but ignore files with word 'test'.
...
I'm working in C# doing some OCR work and have extracted the text I need to work with. Now I need to parse a line using Regular Expressions.
string checkNum;
string routingNum;
string accountNum;
Regex regEx = new Regex(@"\u9288\d+\u9288");
Match match = regEx.Match(numbers);
if (match.Success)
checkNum = match.Value.Remove(0, 1).R...
Hi
How can I extract the longest of groups which start the same way
For example, from a given string, I want to extract the longest match to either CS or CSI.
I tried this "(CS|CSI).*" and it it will return CS rather than CSI even if CSI is available.
If I do "(CSI|CS).*" then I do get CSI if it's a match, so I gues the solution i...
I have a CSV file I'm importing but am running into an issue. The data is in the format:
TEST 690, "This is a test 1, 2 and 3" ,$14.95 ,4
I need to be able to explode by the , that are not within the quotes...
...
I apologize for the terrible title...it can be hard to try to summarize an entire situation into a single sentence.
Let me start by saying that I'm asking because I'm just not a Regex expert. I've used it a bit here and there, but I just come up short with the correct way to meet the following requirements.
The Regex that I'm attemptin...
I'm trying to use sed to replace whitespace within a string. For example, given the line:
var test = 'Some test text here.';
I want to get:
var test = 'Sometesttexthere.';
I've tried using (\x27 matches the '):
sed 's|\x27\([^\x27[:space:]]*\)[[:space:]]|\x27\1|g
but that just gives
var test = 'Sometest text here.';
Any ideas...
I'd like to test whether a string contains "Kansas" followed by anything other than " State".
Examples:
"I am from Kansas" true
"Kansas State is great" false
"Kansas is a state" true
"Kansas Kansas State" true
"Kansas State vs Kansas" true
"I'm from Kansas State" false
"KansasState" true
...
This interesting question http://stackoverflow.com/questions/2837267/ concerned how to do a negative look-ahead in MySQL. The poster wanted to get the effect of
Kansas(?! State)
because MySQL doesn't implement look-ahead assertions, a number of answers came up the equivalent
Kansas($|[^ ]| ($|[^S])| S($|[^t])| St($|[^a])| Sta($|[^t])...
I have this so far:
chrome.tabs.getSelected(null, function(tab)
{
var title = tab.title;
var btn = '<a href="' + tab.url + '" onclick="save(\'' + title + '\');"> ' + title + '</a>';
if(tab.url.match('/http:\/\/www.mydomain.com\/version.php/i'))
{
document.getElementById('link').innerHTML = '<p>' + btn + '</p>'...
I want to perform a regex using grouping. I am only interested in the grouping, its all I want returned. Is this possible?
$haystack = '<a href="/foo.php">Go To Foo</a>';
$needle = '/href="(.*)">/';
preg_match($needle,$haystack,$matches);
print_r($matches);
//Outputs
//Array ( [0] => href="/foo.php"> [1] => /foo.php )
//I want:
//A...
Hello All,
I am trying to develop a complex textual search engine.
I have thousands of textual pages from many books.
I need to search pages that contain specified complex logical criterias.
These criterias can contain virtually any compination of the following:
A: Full words.
B: Word roots (semilar to stems; i.e. all words with certa...
I suck at regex, I only managed to get so far preg_match("/http:\/\//", $url).
I need this for a php script
...