PHP-Function rewrite htmlsource

Completed Posted Dec 27, 2009 Paid on delivery
Completed Paid on delivery

The function should take a html-source-string and replace parts of it according to the information given in a second parameter (array).

## Deliverables

This should be a easy for an experienced php-programmer.

**PHP-Version: 5.2**

The function should take a html-source-string and replace parts of it according to the information given in a second parameter (array):

The Array contains the following fields/information:

* **'searchpattern'** : a regular expression whose matches in the html-source should be replaced according to the following rules:

* **'replacepattern'**: the matching regular expression computing the replacement string - or empty if no replacement should be done

* **'link' ** : an URL the resulting pattern (or the original if 'replacepattern' is empty ) should be linked to - or nothing if empty

* **'start' ** : the # of the occurance that should be replaced (i.e. 3 => don't replace the first two occurances) - default: 1

* **'skip'** : the # of occurances that should be skipped after the first replacement (i.e. 1 - skip 1 then replace the next then skip 1 again and so on...) default: -1 (special value: only once!)

* **'casesensitive'** : if true the regular expression should be case sensitive, if false not - default: true

* **'fullwordsonly'** : if true only fullwords should be replaced, if false also parts of words should be replaced - default: true

and should the replacement string be part of another searchpattern match it should not be counted as such!

*Example: source: "*abc def ghi jkl*", first searchpattern:* def*, first replacement:* jkl*, second searchpattern:* jkl*, second replacement:* xyz*, the result should be: "*abc jkl ghi xyz*"

*

There are two more rules to obey:

* Never! replace strings within an URL (within an a-tag)

*Example: source: 'whatever <a href="[url removed, login to view]">abc</a> and some more...', searchpattern: abc, replacement: xyz, then the result should be: 'whatever <a href="[url removed, login to view]">xyz</a> and some more...'*

* Don't wrap a link around the result if it's already in a link

*Example: source: 'whatever <a href="[url removed, login to view]">abc jolly be good</a> and some more jolly ...', searchpattern: jolly, replacement: xyz, and link: [url removed, login to view] then the result should be: 'whatever <a href="[url removed, login to view]">abc xyz be good</a> and some more <a href="[url removed, login to view]">xyz</a>* ...'

Upon Agreement I will provide more testing examples (including the desired results)

Engineering MySQL PHP Software Architecture Software Testing

Project ID: #3046132

About the project

13 proposals Remote project Active Dec 30, 2009

Awarded to:

rajamanickam1000

See private message.

$25.5 USD in 16 days
(78 Reviews)
5.8

13 freelancers are bidding on average $78 for this job

dancoderdan

See private message.

$85 USD in 16 days
(57 Reviews)
6.5
Andreena

See private message.

$63.75 USD in 16 days
(261 Reviews)
5.9
Eliteprog

See private message.

$34 USD in 16 days
(31 Reviews)
5.6
khalidsafwatvw

See private message.

$72.25 USD in 16 days
(64 Reviews)
5.5
edreamzinc

See private message.

$80.75 USD in 16 days
(24 Reviews)
5.1
sumon4work

See private message.

$67.15 USD in 16 days
(42 Reviews)
4.7
svasti

See private message.

$42.5 USD in 16 days
(13 Reviews)
3.6
sahilsakhujavw

See private message.

$212.5 USD in 16 days
(2 Reviews)
2.2
spiderzsolutions

See private message.

$143.65 USD in 16 days
(1 Review)
2.0
masifnawaz

See private message.

$85 USD in 16 days
(6 Reviews)
2.0
touseefphpm

See private message.

$85 USD in 16 days
(2 Reviews)
2.0
twandreih

See private message.

$19.55 USD in 16 days
(0 Reviews)
0.0