Käynnissä

Easy RegEx for PHP JavaScript

1. We need a regular expression to split the html content into multiple pages (for pagination) and store them in PHP array. (please check the html example bellow)

The end of the "page" is described with the following tag: <hr class=”some-pagebreak” />

The RegEx should find this tags and return the HTML "page sections" into a PHP array.

2. Regular expression to extract a section of text from a tag. The Regexes is needed in Javascript and PHP.

This is the sample scenario where we require the Regex to work:

Javascript:

- Function to wrap selected html in the following tag: ‘<span class=”pragma-teaser”>’ and ‘</span>’. Please check the html example bellow.

- CONDITION: There should be only one paragraph that is embedded in the above mentioned span tag . We need another Regex function that will search for an instance of this tag and if it finds it it should remove it from that paragraph an apply it to the selected html.

- We also need Regex for stripping the ‘<span class=”pragma-teaser”>’ and ‘</span>’ tags if we want to remove teaser. So we need another RegEx that will remove this tag and leave the inner HTML untouched.

- PHP:

Extract the html content contained in ‘<p class=”pragma-teaser”>’ and ‘</p>’ for

Remove ‘<p class=”pragma-teaser”>’ and ‘</p>’ when displaying the full article

html EXAMPLE

var html = '<h2><span class="editsection">[<a href="/w/[url removed, login to view];amp;action=edit&section=5" title="Edit section: Equipment">edit</a>]</span> <span class="mw-headline">Equipment</span></h2>

<div class="rellink boilerplate seealso">See also: <a href="/wiki/Lightsaber" title="Lightsaber">Lightsaber</a></div>

<p>Within the Star Wars universe, the Jedi are usually portrayed as dressed in simple robes and carrying specialized field gear for their missions. The most notable instrument wielded by a Jedi is the <a href="/wiki/Lightsaber" title="Lightsaber">lightsaber</a>.</p>

<p>Lightsabers are used by both Jedi and Sith. Jedi commonly wield blue and green lightsabers in the movies, while the Sith tend to wield red ones. Jedi <a href="/wiki/Mace_Windu" title="Mace Windu">Mace Windu</a> (<a href="/wiki/Samuel_L._Jackson" title="Samuel L. Jackson">Samuel L. Jackson</a>) and Siri Tachi (from Expanded Universe books) wield unique purple lightsabers. Master Yaddle was known to wield an orange lightsaber. The former Jedi Padawan Ferus Olin, from Expanded Universe books, wielded a red blade. However, he was not a <a href="/wiki/Sith" title="Sith">Sith</a>.</p>

<p>In the Expanded Universe of Star Wars media, there were a vast variety of lightsaber colors. In <i><a href="/wiki/Star_Wars:_Knights_of_the_Old_Republic" title="Star Wars: Knights of the Old Republic">Knights of the Old Republic</a></i> video game, the colors signified the Jedi's specialization.</p>

<p><br /></p>’;

var text = ‘Within the Star Wars universe, the Jedi are usually portrayed as dressed in simple robes and carrying specialized field gear for their missions. The most notable instrument wielded by a Jedi is the <a href="/wiki/Lightsaber" title="Lightsaber">lightsaber</a>.';

After replace:

html = '<h2><span class="editsection">[<a href="/w/[url removed, login to view];amp;action=edit&section=5" title="Edit section: Equipment">edit</a>]</span> <span class="mw-headline">Equipment</span></h2>

<div class="rellink boilerplate seealso">See also: <a href="/wiki/Lightsaber" title="Lightsaber">Lightsaber</a></div>

<p><span class=”pragma-meta”>Within the Star Wars universe, the Jedi are usually portrayed as dressed in simple robes and carrying specialized field gear for their missions. The most notable instrument wielded by a Jedi is the <a href="/wiki/Lightsaber" title="Lightsaber">lightsaber</a>.</span></p>

<p>Lightsabers are used by both Jedi and Sith. Jedi commonly wield blue and green lightsabers in the movies, while the Sith tend to wield red ones. Jedi <a href="/wiki/Mace_Windu" title="Mace Windu">Mace Windu</a> (<a href="/wiki/Samuel_L._Jackson" title="Samuel L. Jackson">Samuel L. Jackson</a>) and Siri Tachi (from Expanded Universe books) wield unique purple lightsabers. Master Yaddle was known to wield an orange lightsaber. The former Jedi Padawan Ferus Olin, from Expanded Universe books, wielded a red blade. However, he was not a <a href="/wiki/Sith" title="Sith">Sith</a>.</p>

<p>In the Expanded Universe of Star Wars media, there were a vast variety of lightsaber colors. In <i><a href="/wiki/Star_Wars:_Knights_of_the_Old_Republic" title="Star Wars: Knights of the Old Republic">Knights of the Old Republic</a></i> video game, the colors signified the Jedi's specialization.</p>

<p><br /></p>’;

Taidot: Javascript, PHP

Näytä lisää: javascript regex teaser, w split, work n gear, the gear page, text easy, split page html, search red, search for work, search for red, scenario wiki, regular expression no, regular expression in c, regular expression function, regular expression example, regular expression c, regular expression a, regular expression 0, regex is, regex in c, regex example, regex c, red search, php tags, master find, index. hr

About the Employer:
( 15 reviews ) Skopje, Macedonia

Projektin tunnus: #473940

Myönnetty käyttäjälle:

deOne

It is so very easy task.

30 $ USD 0 päivässä
(8 arvostelua)
3.5

17 freelanceria on tarjonnut keskimäärin 110 $ tähän työhön

sanjay2004

Please view PM to discuss ahead towards start.

211 $ USD 4 päivässä
(515 arvostelua)
9.5
soner

I can do usch regexp easily. Please contact.

180 $ USD 0 päivässä
(129 arvostelua)
8.2
phpexp

Please check the PMB.

125 $ USD 3 päivässä
(187 arvostelua)
8.0
VALUEONWEB

I am ready to do this for you

200 $ USD 3 päivässä
(212 arvostelua)
7.9
sureshdevi

I can do this work. Thanks, Suresh

75 $ USD 2 päivässä
(744 arvostelua)
7.6
zeke

Dear Customer! I am very experienced with regexp's. Please see PMB for examples of my previous work related to this field. Ready to start right now and finish within several hours. My bid is for fast professional servi Lisää

100 $ USD 0 päivässä
(168 arvostelua)
7.1
kernelbd

We can do this thanks.

200 $ USD 0 päivässä
(111 arvostelua)
6.8
dreamci

hello , please check pm

50 $ USD 1 päivässä
(62 arvostelua)
6.3
ShimaSoft

I use regex very often. Will be glad to help you.

30 $ USD 1 päivässä
(27 arvostelua)
6.0
charlietfl

would be happy to do this today for you

80 $ USD 0 päivässä
(57 arvostelua)
6.1
ezee

Hello sir, i can start work on this project from now. please check PMB. thanks.

190 $ USD 3 päivässä
(48 arvostelua)
5.6
pdah

Hi there, please check your PMB

70 $ USD 1 päivässä
(15 arvostelua)
5.3
magic2goodil

I have a lot of experience with Regular expressions as well as PHP and Javascript. I can knock this project out for you in 1 day no problem.

75 $ USD 1 päivässä
(3 arvostelua)
3.8
osfreelancer123

let me start, thanks, have a nice day, plz check your private message.

200 $ USD 5 päivässä
(8 arvostelua)
3.6
MsZola

I'd be glad to take care of this for you, please see pm

50 $ USD 1 päivässä
(2 arvostelua)
3.0
aduyng

I can do it with my strong experience in Regex. I have done 2 website already which are using Regex to extract data. Contact if interested.

100 $ USD 1 päivässä
(0 arvostelua)
0.0
paayal

Hi,I am interested ...please check PMB -Paayal

100 $ USD 2 päivässä
(0 arvostelua)
0.0