Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preg_match/replace ors substr in a Nutshell 1

Status
Not open for further replies.

rimbaud1964

Programmer
Aug 25, 2006
8
DE
howdy - good day phpFreaks,

well i want to apply the preg_match to a special task want to perform a regular expression match

preg_matc - what does it do;

int preg_match ( string pattern, string subject [, array &matches [, int flags [, int offset]]] ) Searches subject for a match to the regular expression given in pattern.
If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.

we believe: we guess that ereg is a regular expression function, based on the POSIX regular expression standard. Preg (Based on PCRE) should be used instead, as its more extensive, often faster, and POSIX will disappear into PCECL in future versions). In likelihood, we ll take the source code and use preg_match/replace or substr on it, searching for the bits you need. Using PCRE modifiers, we can specify that the file's contents are treated as
a single line, which negates the need for linebreak sanitization.

job i want to run preg_match/replace or substr on a file;

So out of intuition and looking at some examples i managed to come up with these data...

see http://www.phpbbdoctor.com/doc_tables.php see the sourcecode and have alok at it:

phpbb_categories
phpbb_forums Forums for your board.
phpbb_groups A group of users
phpbb_posts Posts for your board.
phpbb_posts_text The text for the post
phpbb_topics Topics for your board.
phpbb_users Base user information,
and the timestamp - i need the timestamp.

how to parse the Source - of a example page http://www.phpbb.de/viewtopic.php?t=129465&view=next
see the sourcecode and now imagine - i need the data

categories,
forums
posts
post_texts
post_topics
users

Finds all data on web page with that have to do with the data

http://www.phpbbdoctor.com/doc_tables.php but how do we proceed.

i want to run the preg_matc the results should go into an ARRAY that can be taken to a database, a phpBB-database with certain tables, were the data were put in.

i hope that i colud tell whats needed. And now i need some advices.

btw - can we benefit from this


look forward to hear from you

regards rimbi
 
i speak a bit of german but even with that knowledge i'm at a loss to understand what you are actually asking.

a stab in the dark (complete guess):

you have a bulletin board and wish to parse bbcode to html.
you then wish to have the results of the parsed info uploaded to a database

answer:
there was a thread here recently that proposed a preg_match solution to this. search through the history - it's only a few days old.
or use the PEAR:BBCode parser
i'm not sure why you want results to be in array to upload them to a database but this would be as simple as
Code:
$array = array($result1, ...);
 
Hello jpadi,

many thanks for replying. great to hear form you. You seem to have German Ancestors, don´t you?
many greetings from Europe.


Well if i do not need to put the data into an array then i can choose a solution without an
array. It depents. To explain the things, that i want to do. I am interested in a
special method of reading bulletin boars - a phpBB-board. See an example here http://www.phpbb.com/phpbb

Well i want to build a content reader (and storage) that runs witout a browser - We can say that
i want to read a phpBB offline. So therefore i am in need of a special method of "reading out"
the data. - I have some perl scrpts that do the job. i can you explain the things if you are interested.
Here is a link to the perl script that fetches the pages [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1271371&page=1 [/url]


the perlscript fechtes the threads and now i need to parse it and storage it locally - in a phpBB-database.

btw here we have an examle thread: [URL unfurl="true"]http://www.phpbb.de/viewtopic.php?p=7541 [/url] some
of the threds have 2, some have 20 postings in it. So what is needed - i am interested in the following tables

http://www.phpbbdoctor.com/doc_tables.php ] here are the informations i am interested in:

phpbb_categories
phpbb_forums Forums for your board.
phpbb_groups A group of users
phpbb_posts Posts for your board.
phpbb_posts_text The text for the post
phpbb_topics Topics for your board.
phpbb_users Base user information,
and the timestamp - i need the timestamp.

how to parse the Source - of a example page http://www.phpbb.de/viewtopic.php?t=129465&view=next
see the sourcecode and now imagine - i need the data

categories,
forums
posts
post_texts
post_topics
users

Finds all data on web page with that have to do with the data
http://www.phpbbdoctor.com/doc_tables.php but how do we proceed.


here is a link to the perl script that fetches the pages [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1271371&page=1 [/url]


hope i have explained the problem no correct. if you need any more information then let me know!
i will respond soon.


and now many greetings from Europe. I look forward to hear from you.

greetings
rimbi,


btw; finally - some explanations - why the whole fuss; i am currently writing a little study bout
online dicussion and the implications - tehrefore i am in need of some data to analyze with some
linguistic methods. I get those data out of forums - PHPBB-forums, nothing harmful - but i need
about 700 to 1000 threads with all the above mentionde informations...
btw: Just in case, you are interested in more explanation bout the methods of resarch i can provide them... no problem..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top