I'm working with QString (Qt 4.8) and I want to extract this kind of string src="http://media.cineblog.it/9/91f/Big-Bad-Wolves-primo-trailer-per-il-crime-thriller-israeliano.jpg"
from QString using QRegExp. But I can't find the righ regular expression to do it. The string isn't in a img tag.
Asked
Active
Viewed 77 times
-1

user2508526
- 1
- 2
-
what did you try ? please post your code, sample source data and expected output – Ian Kenney Jun 21 '13 at 10:06
-
I've tried this pattern src\\s*=\\s*\"(.+)?\' – user2508526 Jun 21 '13 at 10:12
-
1@user2508526, don't change the title to mark the question as answered. Instead mark the answer that helped you as accepted, see [How does accepting an answer work?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). – stema Jun 21 '13 at 10:33
2 Answers
1
try using the pattern
(src="[^"]+")

Ian Kenney
- 6,376
- 1
- 25
- 44
-
2@user2508526: The way it works here is to accept the answer by clicking the check mark top left of the answer, not adding solved to the title :-) – Boris Dalstein Jun 21 '13 at 10:34
0
Even simpler answer:
src=".*"
.* Means "match as much of anything (in this line) that you can".

Tom Lord
- 27,404
- 4
- 50
- 77
-
I am not sure this works as well if there are multiple src="..." on a line – Ian Kenney Jun 21 '13 at 13:59