Questions tagged [rubular]

A Ruby-based regular expression editor and tester.

A Powerful and most efficient Domain for testing Regular Expressions.

Website: http://rubular.com/

66 questions
0
votes
2 answers

Regular expression for DSL

I'm trying to write a regular expression that captures two groups: the first is group of n words (where n>= 0 and it's variable) and the second is a group of pairs with this format field:value. In both groups, the individuals are separated by blank…
tehAnswer
  • 960
  • 1
  • 13
  • 28
0
votes
1 answer

How can I get my Regular Expression to take the first match, and ignore any following matches?

I am making regular expressions to extract dosage instructions from a pharmaceutical catalog. I am getting information from many different brands, and formatting is not consistent even within a brand so my expression has to be kind of lenient. The…
mudfaerie
  • 3
  • 2
0
votes
3 answers

ruby regex: How to extract string from url

not very familiar with rubular, would like to know how to use Ruby regex to extract "postreview-should-be-the-cause" from "{\"source_url\"=>\"http://testing.com/projects/postreview-should-be-the-cause\"}" the best I am getting is check_user =…
chickensmitten
  • 477
  • 6
  • 16
0
votes
2 answers

Regular expression for XML tag

I am having a hard time matching the following text: Dummy Dummy Using the following Regex: /.*<\/Reports>/ I am using rubular (I am using ruby) to test it , but…
0
votes
3 answers

Find all characters in string with comma using regular expression

I want to search all '2' s in the string below: 2, 10,11,1,1, 22,1,12,1,1, 1,2 , 2 ,2 I gave regular expression: (^\s*(2)\s*)|(\s*,\s*(2)\s*(,|$)) But it will not search last but one 2. I changed regular expression now…
SHRI
  • 2,406
  • 6
  • 32
  • 48
0
votes
3 answers

Regex selects first to last instead of just first

I'm trying to use String.sub! in ruby and it substitutes way too much. The regex i'm using. You can see it's matching too much: http://rubular.com/r/IUav4KEFWH .+<\/rb> it selects from the first to the last and I want it just to select the…
maek
  • 1
  • 2
0
votes
4 answers

Match the text between two words (Words don't repeat in matched text)

I have the following as my Input, Input Random Line 1 Random Line 2 From: person1@example.com Date: 01-01-2011 To: friend@example.com Subject: One Random Line 3 Random Line 4 From: person2@example.com Subject: Two Random Line 5 From:…
MIZ
  • 385
  • 1
  • 14
0
votes
1 answer

Ruby Regex: Rejecting selected URLs

A survey software I'm using allows to exclude sites on which the survey should be shown using Ruby based Regex (they recommend testing strings on rubular.com). I don't want to show the survey to clients that are close to finishing transaction, so…
Matt
  • 75
  • 3
  • 11
0
votes
1 answer

Regex matches space between characters

I have this regex (\((-?\d+.\d+\s?-?\d+.\d+,?)+\))* that seems to be matching the space between characters at the very beginning of the string along with the parts that I would like to match.How can I change my regex to not match these as it causes…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
0
votes
1 answer

Is there an easy Regex expression to capture a reference code that continuously changes?

Let's say I have a string: Success: Feed File Uploaded. Use the reference code afc3d6e84df84f51944a06cccee8f59a to track these records in the logs. What I need to capture is the reference code only, the afc3d6e84df84f51944a06cccee8f59a. It's 32…
Christopher Bruce
  • 661
  • 3
  • 10
  • 24
0
votes
1 answer

Regex to capture everything except the text that is coherent

I have this string and other ones like it:
Christopher Bruce
  • 661
  • 3
  • 10
  • 24
0
votes
1 answer

Ruby and Regex Imprecision

I'm trying to use Ruby and Regex to divide a long string into chunks separated by timestamps that occur throughout the string. "10:59 a.m. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at tincidunt >ante. 3:30 a.m. Aenean…
acdanger
  • 17
  • 1
  • 4
0
votes
3 answers

Rails Regular Expression

I'm really new to regular expression. I have the following url: http://www.foo.bar.com/hgur_300x300.jpg and http://www.foo.bar.com/hgur_100x100.jpg How would I use gsub with regular expression in rails to find [300X300.jpg AND 180X180.jpg] and…
Yogzzz
  • 2,735
  • 5
  • 36
  • 56
0
votes
1 answer

Anomaly in Regex output

I am having different outputs on regex matching 1) when using Rubular and 2) other when using rails console or irb environment. 1) Rubular /\w+/ on test string "---\n- nicidnut\n" matches " n nicidnut n" (I have shown only matched part and…
shailesh
  • 865
  • 1
  • 11
  • 18
0
votes
2 answers

Removing parenthesis and digit from string with regex

I have strings that look like this: Executive Producer (3) Producer (0) 1st Assistant Camera (12) I'd like to use a regex to match the first part of the string and to remove the " (num)" part (the space preceding the parentheses and the…
kcurtin
  • 521
  • 1
  • 6
  • 18