title: sed : extract multiple fields in random order
body: <p>I have a paragraph as below </p>
  
  <blockquote>
    <p>Hello, this is pattern1=somedata and pattern2=someotherdata and
    something else after this along with pattern3=data_again and
    pattern4=wellstilldata and nothing more. </p>
  </blockquote>
  
  <p>And I am able to extract those patterns values with, </p>
  
  <pre><code>sed -r 's/.*pattern1=([^ ,]+).*pattern2=([^ ,]+).*pattern3=([^ ,]+).*pattern4=([^ ,]+).*/\1\t\2\t\3\t\4/' file.txt
  </code></pre>
  
  <p>but there are some cases where pattern will be in random positions , I mean there is no condition as such always pattern1 should come first and pattern4 should come at last and pattern string may not be pattern always but it will be one of the given pattern in above sed logic. their positions may vary but my above logic of extracting multiple fields from paragraph will only work if they are in order or else I have to re arrange them in order everytime. </p>
  
  <p>But is there any we can modify above logic to work like irrespective of position of patterns and string is not "pattern" always but they will be in my sed logic.</p>
  
  <p>Thank you.  </p>