473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

searching phrase (text) in html file

ash
I want search phrase in html file and mark (like Google when I click on
"cached") it (phrase). Does somebody know any class, that can help me? Maybe
somebody know how could I make this?
thanks
Jul 17 '05 #1
4 1727

ash wrote:
I want search phrase in html file and mark (like Google when I click on "cached") it (phrase). Does somebody know any class, that can help me? Maybe somebody know how could I make this?
thanks


$new_html = str_replace ($phrase, '<span
style="css_statement">'.$phrase.'</span>', $old_html);

could be a way.
i didn't test that, if $phrase contains html tags it might mess up your
markup.

micha

Jul 17 '05 #2
ash
> i didn't test that, if $phrase contains html tags it might mess up your
markup.

Yes. I want avoid html tags.
Jul 17 '05 #3

ash wrote:
i didn't test that, if $phrase contains html tags it might mess up your markup.

Yes. I want avoid html tags.


i'm not sure what you mean but here's an example:

$old_html = '<p>some text and some more text</p>';
$phrase = 'text';

so, using above said function
$new_html = '<p>some <span style="put your style here">text</span> and
some more <span style="put your style here">text</span></p>";

all fine

now: $phrase = '<p>some';

$new_html = <span style="put your style here"><p>some</span> text and
some more text</p>";
clearly messed up html

which means: if your search phrases do not contain html tags, above
solution is fine. if they contain tags it's more complicated. i don't
have a solution for that right now.

micha

Jul 17 '05 #4

ash wrote:
i didn't test that, if $phrase contains html tags it might mess up your markup.

Yes. I want avoid html tags.


i'm not sure what you mean but here's an example:

$old_html = '<p>some text and some more text</p>';
$phrase = 'text';

so, using above said function
$new_html = '<p>some <span style="put your style here">text</span> and
some more <span style="put your style here">text</span></p>";

all fine

now: $phrase = '<p>some';

$new_html = <span style="put your style here"><p>some</span> text and
some more text</p>";
clearly messed up html

which means: if your search phrases do not contain html tags, above
solution is fine. if they contain tags it's more complicated. i don't
have a solution for that right now.

micha

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Follower | last post by:
Hi, I am working on a function to return extracts from a text document with a specific phrase highlighted (i.e. display the context of the matched phrase). The requirements are: * Match...
2
by: Michi | last post by:
Hello, I am creating a databse with a large number of text (or blob?) entries. I want users to be able to search these fields. An example would be a forum or journal. Indexing every word in...
1
by: silver_animal | last post by:
Greetings, Hopefully this posting is clear to both newsgroups. I have been looking for a way to open a PDF file and automatically locate and go to a certain phrase within the file. The phrase...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
5
by: sree078 | last post by:
Hi I've a list of Values with varchar field in main in a table. I wanted to have fast search as there are very less insertions/updations. Thought to do a FullText Searching on that varchar field....
4
by: sandeepkavade | last post by:
Hi all, i want to search for files containing particular phrase, just like windows "A word or phrase in file:" utility in search option. Does anybody knows any windows API or programming logic for...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
9
by: C#_Help_needed | last post by:
I need help with the following question. THANKS :) Write a program in c# that takes in a directory as a command line parameter, and returns the longest repeated phrase in ALL text files in that...
1
by: chromis | last post by:
Hi, I've been trying to create a carousel class which takes an array of phrases and then creates a textfield for each one positioning it vertically based on the order it was added. The next stage...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.