Can someone help with a regular expression?

by Tedel
4 replies
Hello,

If you don't mind a free tip for a newbie, I have a list of 70 words, and I need to repeat each 10 times to add up 700 times 70 sets of words repeated 10 times each.

Can you save me the copy-paste nightmare with a regular expression? I have Linux or Notetab Light in Windows. The first one allows for, the second one allows regexes in Perl.

Thanks!
#expression #regular
  • Profile picture of the author KirkMcD
    You use RegEx mainly to find something and then maybe replace it with something else, not just to copy and paste something.

    How is pasting something 10 times a nightmare?

    An example of what you want to do would be really helpful.
    {{ DiscussionBoard.errors[4206082].message }}
  • Profile picture of the author Tedel
    I want to turn this...

    a
    b


    ...into...

    a
    a
    a
    a
    a
    a
    a
    a
    a
    b
    b
    b
    b
    b
    b
    b
    b
    b
    b


    ...You get it. I want to replace a for a,a,a,a,a,a,a,a,a,a,a in short. Can it be done?
    Signature
    Author of Heptagrama. PM for my SEO service offer.
    {{ DiscussionBoard.errors[4214934].message }}
  • Profile picture of the author mozlost
    Yes, assuming that you have access to a bash shell (i.e. do you have shell access on your server?)
    Put each line (in your example it was a,b...) into a file (in my case I used foo.txt)
    Then run this double for-loop...

    for line in `cat foo.txt`; do for i in {0..9}; do echo $line; done; done
    {{ DiscussionBoard.errors[4217607].message }}
  • Profile picture of the author Tedel
    Thank you.
    Signature
    Author of Heptagrama. PM for my SEO service offer.
    {{ DiscussionBoard.errors[4222195].message }}

Trending Topics