1

Noob with regular expressions. Each line in my text file has several fields, of which I want to extract two: the first and a second that isn't always in the same place. What I have:

"Silicone Rubber" envdata="1" matid="232" failurecriteria="4" "S-Glass Fiber" matid="62" failurecriteria="4" envdata="1" 

What I want:

"Silicone Rubber" matid="232" "S-Glass Fiber" matid="62" 

Can anyone show me how to do this?

2
  • Is the first field to select always at the begining of a line? Commented Feb 28, 2020 at 16:17
  • Yes, always; only the second field moves around Commented Feb 28, 2020 at 16:40

1 Answer 1

0

Use for example the following:

Find what: ^("[\w \-\(\)]*").*( matid="\d*").*
Replace with: \1\2

3
  • Thanks, works but seems to be defeated by parens in the first field which I didn't notice before. Example: "POLYURETHANE (11671)" envdata="0" matid="229" failurecriteria="4" is not affected (want "POLYURETHANE (11671)" matid="229"). Any suggestions? Commented Feb 28, 2020 at 16:23
  • No problem : just add (escaped) parenthesis to the search, as above. Commented Feb 28, 2020 at 16:38
  • Following your suggestion I had to add a few more escaped chars: ^("[\w \-()\,\.\%*\;\-\/]*").*( matid="\d*").* but now it works perfectly. Many many thanks! Commented Feb 28, 2020 at 16:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.