I need a quick expression to be able to pull out all the data in a text file that looks like "http:// some random url etc" So it should grab any string that begins with "http:// and ends with " There are other double quotes in the file but I only want the ones that start with "http:// and the closing quotes for each incident of that.
---------- Post updated at 04:00 PM ---------- Previous update was at 03:46 PM ----------
I should mention the double quotes are actually in the file, I wasn't adding them myself.
---------- Post updated 12-18-09 at 08:32 AM ---------- Previous update was 12-17-09 at 07:30 PM ----------
Could someone please explain why it worked? I thought [^"] would mean to grab a string that begins with a double quote. I see also the dbl quotes enclosed in single quotes. I would love to hear a rundown of how it all worked though.
[^"] means "any character other than a quote", just like [^q9] means "any character other than q or 9". [^"]* means "zero or more characters that aren't quotes", and so [^"]*" means "any number of non-quotes followed by a quote".
You may want to google 'regular expresssion'. IF you want to become proficient in unix, regex. as it is called is a very important tool. It has spilled over into Windows programming in the past few years as well.
This is not correct. You may want to search for "greedy matching", and look up the -o option. Also your quoting alternatives will prohibit the regex from being properly evaluated.
No that will only work if there is one address per line and if there are no further "-characters on that line. You may want to search for "greedy matching".
Hi aaiaz, if your grep does not support the -o option then you have to either download a grep that can or use a sed/awk/shell script. It can not be accomplished with a regular grep statement.