Hi Marck, On Wednesday, January 1, 2003 at 17:05 GMT +0000, a stampede was started when Marck Pearlstone [MP] hollered:
MP> (.*?) A recorded pattern consisting of any character (the MP> target for the extraction. Final '?' means "may or may MP> not be present". A minor fix on this excellent breakdown. The final ? in the bit above makes the * repeat operator ungreedy. For anyone who doesn't know, without the ?, .* will match as much as it possibly can and still have the rest of the expression work. By making it ungreedy, .*? will match the least it can and have the rest of the expression work. An example: =====[Begin Sample Text]===== "This is the first quote" "This is a second quote" =====[ End Sample Text]===== Now suppose I want to extract the contents of the first quote above. I might use an expression like: %RegexpText='\".*\"' But this would match: =====[Begin Output 1]===== "This is the first quote" "This is a second quote" =====[ End Output 1]===== With the ungreedy option, the expression becomes: %RegexpText='\".*?\"' Now the output is: =====[Begin Output 2]===== "This is the first quote" =====[ End Output 2]===== If you run the above macros on this message, the results will be slightly different in the first case. It's a good illustration of the difference between greedy and ungreedy. -- Thanks for writing, Januk Aggarwal Ok, who is General Relativity, and what did he do with Sir Newton? ________________________________________________________ Current version is 1.61 | "Using TBTECH" information: http://www.silverstones.com/thebat/TBUDLInfo.html
