Ruby String::gsub! pausing unexpectedly?

Without knowing anything else about your environment, or the type of files you're reading, I would suggest trying to make your kleene stars to be non-greedy. Like, change (.|\s) to (.|\s)*?

Without knowing anything else about your environment, or the type of files you're reading, I would suggest trying to make your kleene stars to be non-greedy. Like, change (.|\s)* to (.|\s)*?

That worked surprisingly well, the script executed flawlessly! But could you explain to me exactly what that did, I'm still not sure what is going on? Thanks!

– John Jun 25 '10 at 17:28 For details, see the descriptions of * and *? Here: regular-expressions. Info/reference.

Html – bta Jun 25 '10 at 17:37 2 'Greedy' matching starts with the largest possible match and shrinks it until it finds the proper match. 'Lazy' matching starts with the smallest possible match and expands it. For example, take the string abc "def" "ghi" jkl.

The 'greedy' regex ". *" would match "def" "ghi" and the 'lazy' regex ". *?" would match "def".

– bta Jun 25 '10 at 17:42 I'm guessing it's trying to find the longest possible match in a long document, so it's taking a long time to traverse the whole document. – Ken Bloom Jun 25 '10 at 18:58 @Ken Bloom - it's actually a fairly small document. @bta - thanks!

That makes a lot of sense. – John Jun 25 '107 at 13:51.

My current method is to iterate through the directory and (for each file) read the file, use String::gsub! To make all my changes (not sure if this is best) and then I write the new contents to the file. This all looks fine and dandy, but for some reason (that I, for the life of me, cannot figure out) the program hangs seemingly arbitrarily at the gsub!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions