Questions tagged "regex" (page No.1)

Literal dot confusion, copy all hidden files

It works fine when I copy all hidden files using regex: cp -r source/\.[^.]* destination/ and it just copies exactly files beggining with a dot . . However, I found the following works also: cp -r source/.[^.]* destination/ In regular expression, doesn't dot . mean "any singular character"? So why does not the second command ...

Selecting text after regex match

I'm really stuck with regex in python. I have a string with items like this: """ (001,002) SI [SomeTag]:Element (001,003e) LO [SomeTag2]:Element2 (001,004r) LR [SomeTag3]:Element3 (001,006) HI [SomeTag4]:Element4 """ And I want to select "Element2". I tried to select the line with me = re.search("\(001,003e\)(.*)", obj) And it gives me the whole line. But I just want "Element2". How ...

Java - parsing text using delimiter for separating different arguments

How would you use multiple delimiters or a single delimiter to detect and separate out different string matches? For example, I use a Scanner to parse in the following string: MrsMarple=new Person(); MrsMarple.age=30; I would like to separate out this string to determine, in sequence, when a new person is being ...

capturing site-wide file downloads with jQuery

I am attempting to use the gaAddons Google Analytics jQuery plugin to track downloads on my site, so any .JPGs, .PNGs, .PDFs etc that have been downloaded I want to track by executing some tracking code. Clearly something is not working correctly, as I cannot seem to get the ...

Javascript RegEx to match URL's but exclude images

I'm close, I can feel it, but something's wrong. I need to replace all text links in a string of HTML text by actual clickable links. Works fine with the following RegEx: /\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi I then noticed it also replaces images and already formatted links. Figures I need to exclude links preceded by ...

Regex exclude bracket symbol

I am trying to use RegEx to find all cells in OO-calc with : [RB]Condition=New the RB part is necessary, as other cells may get caught if it is not specified. the RegEx that would work would be : [RB]Condi.* however the brackets are read as a part of the expression, is there ...

Regex matches next attribute if the desired one is not found. How to restrict it?

Using regex and PHP I am trying to get the content of the title attribute as below. preg_match('/<abbr class="dtstart" title="([^"]*)"/i', $file_string, $starts); $starts_out = $starts[1]; preg_match('/<abbr class="dtend" title="([^"]*)"/i', $file_string, $ends); $ends_out = $ends[1]; Here is the exact part of the code that I want to get, and I get the data correctly. <div id="eventDetailInfo"> ...

Regex Range of numbers or just a number

I had a request for a textbox to have a range of values which I was using the pattern ^(\d{1,3})\-(\d{1,3})$ and that seemed to work. In addition now they want: A positive 2 digit number limited from 0 to 20 OR A positive 2 digit range (01-20 or 1-3 or 1-03 ...

Replace space(x0020) from string in Regex C#

I am not good at Regex, and I think I am close. I have some data coming back from a list and populating a dropdown. I am getting x0200 representation instead of a space. I have tried Regex, but I think I am wrong here. foreach (string field in ...

Replace div with regex

i need to replace all div's containig class "ta" and id "ta_somenumber" with textareas that will keep same attributes. Here is example code: $html_content = '<div class="ta" id="ta_345">sometext</div><span style="...">Some text</span><--!more html--><div class="ta" id="ta_5687">sometext</div>'; Here is what i want to achieve: $html_new_content = '<textarea class="ta" id="ta_345">sometext</textarea><span style="...">Some text</span><--!more html--><textarea class="ta" id="ta_5687">sometext</textarea>'; I was trying with ...

htaccess regex directory to variable

I need to make a 301 redirect for certain URLs from directory to variable. EXAMPLE: http://domain.com/es/stackoverflow --> http://domain.com/stackoverflow?lang=es http://domain.com/he/stackoverflow --> http://domain.com/stackoverflow?lang=he As it is now I have a "directory structure" for each language and it's making seperate URLs for the same page, it just switches the ...

How can I improve this small Ruby Regex snippet?

How can I improve this? the purpose of this code is to be used in a method that captures a string of hash_tags #twittertype from a form - parse through the list of words and make sure all the words are separated out. WORD_TEST = "123 sunset #2d2-apple,#home,#star #Babyclub, #apple_surprise #apple,cats ...

Django regex unicode ignores \w tag

Regex \w seems to ignore my Unicode strings. I created the following function: extras.py # -*- coding: utf-8 -*- def test(word): print re.sub(r'[^\w]+', '', word, re.U) and from the django shell: import extras extras.test(u'שלום') The output is an empty string, while it should be the same as the input, in this example. The purpose of the ...

Get the word after a particular word in a Ruby string?

How do I get the word after a particular word in a Ruby string? For example: From:Ysxrb<abc@gmail.com>\nTo: <xyzn@gmail.com>Subject: xyzabc\nDate: Tue, 19 Jun 2012 03:26:56 -0700\nMessage-ID: <9D.A1.02635.ABB40EF4@ecout1> I just want to get: Ysxrb<abc@gmail.com xyzabc ...

JavaScript/RegExp replace portion of string

I have a string something like: foo title:2012-01-01 bar Where I need to get the 'title:2012-01-01' and replace the date part '2012-01-01' to a special format. I just am not good at RegExp and currently have: 'foo from:2012-01-01 bar'.replace(/from:([a-z0-9-]+)/i, function() { console.log(arguments); return 'replaced'; }) and that returns foo replaced ...

regex to pull out a sentence and the previous 3 sentences and next three sentences

I'm having trouble putting a few different regex together to do what I need. Say I have the text: This is sentence 1. This is sentence two! This is three. This is four. And pepsi middle sentence is here which is five. Here you go six? And this is ...

Regex matching a space a digit and 8 characters

I want to match a string containing, a space any number of digit a space 1-8 characters - (alphanumeric and special characters) example, 01 Stack This is what i tried, \\s\\d+\\s[^.]{1, 8} - i tried here except for ., ...

Trying to capture group in javascript regex (port from c#)

I have this regex var mregex = /(\$m[\w|\.]+)/g; string mstring= "$m.x = $m.y"; So basically capture each instance of $m.[+ any number of alphanumeric or . until another character or the end] I have this working in C# but I'm trying to port it over to javascript, so dropped the name capture. var match = ...

« Previous12345678910 ... 20542055Next »Show All