Search the Community
Showing results for tags 'SRE Help'.
-
Hi Programmers, I have worked with SRE before and I know it's a really powerful tool to get extract exactly what you want from text. However it's a little tricky to use sometimes with a lot of syntax to memorize. I'm having a problem and I know it should work, but I just can't get it to work. Here is my text: :ALONEI~2 cd ALONEI~2 AITD2CRK.COM goto end :ALONEI~3 cd ALONEI~3 AITD3.EXE goto end :ARKANO~1 cd ARKANO~1 start.bat goto end :Ascend cd Ascend ASCEND.EXE goto end What I would like to do is get the text between a label like "Alonel~3" and the line "goto end" below it. Here is what I have to work with: 1. I will always know the name of the label 2. I will NOT know how many lines is between the label and the line "goto end" The SRE I have built so far is this, "(?:\:ARKANO~1)(?:\s*)(.*)(?:\s*)(.*)" ;note, the \s must also have a * because I've found without it, it won't work. Maybe the file uses two different linefeeds in one. Which will give me an array of 0 => cd ARKANO~1 1 => start.bat Now that's good, but the thing is I don't know how many lines will be inbetween, so I'd like to make an unlimited repeating set Something like this, but one that has the proper syntax and works. Here are a few tries and fails I've made: "(?:\:ARKANO~1)[?:\s.]*(?:goto)" ; also note I don't want to capture the line feeds "(?:\:ARKANO~1)((?:\s)|(.))*(?:goto)" "(?:\:ARKANO~1)((?:\s*)|(.*))(?:goto)" "(?:\:ARKANO~1)((?:\s)|(.)){1,}(?:goto)" Basically I need to know how to put special characters into a set and make it repeating. I want to not capture the \s line feeds, but capture anything else and continue until I hit the "goto" text. I've been at this for a few hours so any help is appreciated.
- 11 replies
-
- String Regular Expression
- SRE
- (and 4 more)