0

I got a whole list of those lines:

randomtext1', 'somethingelsehere', 'randomtext2', 'link-to-something', 'random-date', 'randomdate2', 'randomname'),

and I want to be able to extract one of those entrys.

somethingelsehere, link-to-something, ...

So I tried using http://regexr.com/ to get the regexcode that works for this, but i can't figure it out.

My thought was that I could simply "mark" the things I want by saying ignore the first, second and third ' then start at the fourth ' until the fifth ' and ignore the sixth to thirteenth again. That should give me randomtext2.

The problem is, that sometimes there is nothing in between the '', but I want to get that aswell The '' should be included in this so that I would get 'randomtext2' instead of randomtext2.

I tried to understand regex, but it really is extremly complex and pretty hard to understand for me so help would be really appreciated :)

xF4m3

Edit1: Example lines: line 1: 3d-furnaces', '', 'spAnser', 'minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288346-3d-furnace-v1-4', '2015-09-27 13:41:50', '2015-09-27 13:41:50', '3D Furnaces'), line 2: 4space', 'No idee what to put here, but it sometimes is there', '4spaceTeam', '4space.mods.center/#download', '2015-09-27 15:45:27', '2015-09-27 15:45:27', '4Space'),

I want to extract 'spAnser' and 'minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288346-3d-furnace-v1-4' from the first line and '4spaceTeam' and 'mods.center/#download' from the second line.

See http://pastebin.com/7tGJB7kh for a better list

I Used regexr.com aswell as regex101.com I need to extract the 3rd and fourth group "(.?) (.?) (.?) (.?) (.?) (.?), (.?), (.?)," that is my regex code to mark all groups, i do not know how i can exclude group 1-3 and 5-8. Examples can be found on pastebin.

xF4m3
  • 21
  • 7
  • 2
    Can you provide the regex you tried and failed, the regex flavor/tool, real input samples and the actual fields you need to extract? – bobble bubble Feb 14 '16 at 12:59
  • "(.*?) (.*?) (.*?) (.*?) (.*?) (.*?), (.*?), (.*?)," that is my regex code to mark all groups, i do not know how i can exclude group 1-3 and 5-8 an example would be here: http://pastebin.com/7tGJB7kh – xF4m3 Feb 14 '16 at 13:05
  • I Used http://regexr.com/ aswell as https://www.regex101.com/ I need to extract the 3rd and fourth group – xF4m3 Feb 14 '16 at 13:12
  • Please [edit] your question and add what you tried, instead of burying it (badly formatted) inside a comment. – Jongware Feb 14 '16 at 13:34
  • This is not a problem that should be solved with regular expressions. – OrangeDog Feb 14 '16 at 15:27
  • How to "exclude group 1-3 and 5-8": Change them from capturing groups `(xxx)` to non-capturing groups [`(?:xxx)`](http://stackoverflow.com/questions/3512471/what-is-a-non-capturing-group). – Andreas Feb 14 '16 at 18:23
  • I leave my [regex approach](https://regex101.com/r/jT6cU5/1) as a comment. – bobble bubble Feb 15 '16 at 12:05

1 Answers1

0

The following regex should do the trick:

(?m)^.*?' *, *'.*?' *, *('.*?') *, *('.*?')

See regex101.com demo using the exact data from your pastebin link.

Andreas
  • 138,167
  • 8
  • 112
  • 195
  • Thanks, that really helped, not what I had in mind, but totally worked like I had hoped it to! Also for everyone who doesn't understand this, just paste this regex into https://www.regex101.com/ , it explains what the diffrent symbloes do. – xF4m3 Feb 14 '16 at 14:49
  • @xF4m3 No need to paste into regex101. Just click the "demo" link I provided, and it'll be pre-filled, with regex *and* your test data. – Andreas Feb 14 '16 at 18:19