How to find words from .txt file using specific pattern

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
firian
Forum Newbie
Posts: 1
Joined: Thu Jul 22, 2010 10:44 am

How to find words from .txt file using specific pattern

Post by firian »

It's my first post here, so hi all.
Anyway, I am trying to work this out, but can't do this alone. I have 30 lines of text, 5 lines for example:

??D
??R?
??T?
?P??
F???

The pattern itself always contains 30 lines that contains words made from 3, 4 or 5 letters. There is always only 1 letter assigned, the ? are wildcards and anything can be placed here. What do I need ? - example:

??D RED
??R? BIRD
??T? BITS

I am trying to assign a random word to every line using the pattern where ??D is any 3-letters word that ends with D etc. I already prepared wordlists, but can't add them as attachment ("The extension txt is not allowed.").

To be honest, I am not a good programmer and have no idea how to make it. Any help or advice will be appreciated.
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: How to find words from .txt file using specific pattern

Post by Gargoyle »

- split the text using explode("\n")
- cycle through the lines using foreach()
- filter each line as you wish
- append strings as you wish
katierosy
Forum Commoner
Posts: 27
Joined: Wed Apr 07, 2010 8:39 am

Re: How to find words from .txt file using specific pattern

Post by katierosy »

If you will search net and read on regular expressions, you may be able to do these tasks with the help of what is already mentioned in this forum.
Post Reply