Tagged Questions
2
votes
2answers
45 views
Ruby Regex and string variable
I am trying to match a string with a non-breaking space ( ) given a variable that contains the string with a regular space. The string I am looking for is the text in a HTML link/anchor and ...
1
vote
2answers
39 views
Regex match including new line
I have a regex to grab everything between "*":
str = "Donec sed odio dui. *Nullam id dolor id nibh ultricies vehicula ut*"
str.match(/\*(.*)\*/)[1]
I want the match to be able to include newline ...
1
vote
5answers
89 views
Extract data from one big string with regex
Consider the following String, which is a table of content extracted from a pdf, like in the following example, two topics can be on one line, there is one line break at the end of each line (like in ...
-1
votes
3answers
29 views
In ruby, how do I split a string into an array, using only the last occurrence of a word [on hold]
I am creating an event, and I would like to be able to parse a single string and populate the model's attributes. As an example, I would like to do the following:
string = "Workout at the gym at 7pm ...
1
vote
3answers
42 views
How to grep elements in array that match patterns from another array?
I have two arrays:
a = ["X2", "X3/X4", "X5/X6/X7", "X8/X9/X10/X11"]
b = ["X9/X10", "X3/X4"]
Now I need to select entries from 'a' array which regexp with any of entries from array 'b'.
Expected ...
0
votes
1answer
31 views
How to catch an word after a mark on the string
I have a string like this: "something_before cl: something_after"
cl: is my mark and I want to catch every word after it. In this case I want to catch the string "something_after". How can I do it?
...
1
vote
3answers
40 views
When Ruby regex doesn't fit on line
When I have a very long regex, like a cucumber step definition, what would be the best way to line wrap it?
example, i would like something like:
When /^I have a very long step definition here in my ...
-1
votes
2answers
37 views
Capture string only on exact matching with ruby
I'm trying to capture a string only when the matching is exact.
I.e.valid:
/this-is-an-exact-matc
/this-is-also-an-exact-match
/this-is-other-exact-match?d=1
/balbabla
Not valid:
...
-2
votes
2answers
40 views
Submatching repeating pattern
I am trying to put together a regexp in VBA, but even in ruby I can't get it right.
the string:
<thead ...
0
votes
2answers
66 views
Regex to match values of hundreds and thousands in Ruby
I am trying to find a working regular expression which allows me to find all prices of a web page which are like 1,150.00 and 500.00
This regular expression works for me in Rubular:
/(\d?,?\d+.\d+)/
...
2
votes
3answers
44 views
Capture string between specific characters
Can someone help me extract the string:
Advice about something
from below:
<TITLE>Advice about something</TITLE>
The expression should be able to capture the string ...
0
votes
1answer
24 views
Regex string for Sublime Text to find email address between two commas
I'm new to regex's and Sublime's and am having issues trying to do a find/replace on all email addresses in a csv file.
I thought it would be reasonably straightforward but seem to be heading down ...
0
votes
2answers
31 views
regex to lazy match possible empty string
I'd like to get anything between A=[ and first enclosing ]:
> str = "Hello A=[apple] B=[boy] World"
> str.match(/A=\[(.+?)\]/)[1]
=> "apple"
So far so good.
However, for A=[]:
> str ...
2
votes
2answers
33 views
Regular expression help to skip first occurrence of a special character while allowing for later special chars but no whitespace
I'm looking for words starting with a hashtag: "#yolo"
My regex for this was very simple: /#\w+/
This worked fine until I hit words that ended with a question mark: "#yolo?".
I updated my regex to ...
1
vote
1answer
35 views
capture content in html comments with regex
I need to capture markup (html) with regex in ruby (yep I know this is bad, but I havent found any alternative as the original markup is really bad formatted).
So I have an original document which ...