0

I'm trying to grab a text enclosed between two words, but the problem is that I can make the regex grab all the text including especial character. Here is an example of what i'm trying to grab:

Example:

Part. 23.00. Random. In this chapter:

(1)Hello 1.

(2)"Hello"2.

Action 10 5th.

I don't want to grab this

Part.12 Hello

Action 12.

I need to grab everything from Part.23 to Part.12 except the "I don't want to grab this" text.

Thank's in advance for the help.

This is my regex: https://regex101.com/r/ginZp8/1

(Sec\.\s*\S+.*\n.*\D.*\D.*|Acts*\D\s.*)
Andrew
  • 6,492
  • 2
  • 29
  • 38
Garen
  • 1
  • 2
  • 5
    Looks like you know what you need to do. Try to do it and you are welcome to ask questions that go beyond "would you write that for me, please?" – Tomalak Jan 23 '17 at 16:22
  • if i knew how to do it i wouldn't ask, i mean i now what i need to do but i don't know how, thats why i ask – Garen Jan 23 '17 at 16:34
  • To give you a great answer, it might help us if you have a glance at [ask] if you haven't already. It might be also useful if you could provide a [mcve]. – Mat Jan 23 '17 at 16:35
  • @Mat I know it's a frustrating comment, but the intent of StackOverflow is not to write code for you when you don't know how to do it. The intent is to help you learn by closing the gaps in your knowledge, and that means you have to come prepared. "I have no idea where to start so I thought I ask you guys" is not preparation. – Tomalak Jan 23 '17 at 16:49
  • @Tomalak ok let me put it this way the regex that i have is not grabbing everything is grabbing like half of the information i need ok – Garen Jan 23 '17 at 17:16
  • Yes, that's a very common problem. A search for "regex matches too much" should already get you started. – Tomalak Jan 23 '17 at 17:19
  • Adding the language and your current regex would also help the question. – chris85 Jan 23 '17 at 17:20
  • @chris85 im only doing regex in regex101.com – Garen Jan 23 '17 at 17:51
  • Where do you plan to use the regex? Regex101 (and regex in general) behaves differently depending on language. – chris85 Jan 23 '17 at 17:55
  • @chris85 i'm planing to use it in c# – Garen Jan 23 '17 at 19:04
  • Okay, I've added the tag. You should add your regex, there is a share option on the regex101 site as well. – chris85 Jan 23 '17 at 19:10
  • You are not specifying the logic for your regex. What are the words that enclose what you want to find? Why would your regex not match "I don't want to grab this"? Do you want to match everything after a "Part ##" until the next one, but ignoring the last line? I read your post several times and I still don't understand your logic. – Andrew Jan 23 '17 at 19:23
  • @chris85 i added my regex now – Garen Jan 23 '17 at 20:06
  • @Andrew i need to grab everything except the "I don't want to grab this" text i mean it should grab something like this Part. 23.00. Random. In this chapter: (1)Hello 1. (2)"Hello"2. Action 10 5th. Part.12 Hello Action 12. – Garen Jan 23 '17 at 20:07
  • @Garen, I understand that. But you haven't answered my question, you basically repeated your original description. I'm asking what is especial about that sentence, how you identify it to make the regex skip it. If instead of "I don't want to grab this", that sentence is "The legal description of the boundary lines", should it be skipped or not? You must give a RULE to the regex so it knows what to match and what not. – Andrew Jan 24 '17 at 17:11

0 Answers0