I am writing a small windows script in javascript/jscript for finding a match for a regexp with a string that i got by manipulating a file.
I know the line number for starting and ending of the search. But I am stuck at this position for a while.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best way to look at something like this is to not overcomplicate your regular expression – you could make it rather unreadable and confusing, particularly if your regex skills aren’t very good. Simplify things first – split the document into an array of lines, pick out your line and then perform your regular expression. Running your regular expression on a smaller string in this fashion could prove to be much faster on very large text files.
splicereturns the array items from the starting index upto and excluding the ending index. You can also provide alimitparameter to thesplitmethod to stop splitting after a certain number of matches. This should improve speed on a large file where the lines you need aren’t near the end.Glossary: