Search and replace

Need to have a script, can be in PHP, Perl or a shell script to convert some text strings that appear in a file. They may appear any number of times in the text file

The basic pattern is <!--[gt ]--> inside there we can expect to see several params

domain, text, plural, count, category, html, tag


<!--[gt text='hello']--> or <!--[gt text='apple' plural='apples' count='2']-->

Quotation may be with single or double quotes. The parameters can appear in any order. You only need to parse text, plural, and count

if plural is not present we need to replace the occurrence with <?php g('text'); ?>

if plural us present we need to replace the string with <?php ng('text', 'plural', 'count'); ?>

the words text, plural and count refer to the value of those parameters.

So a full example:


<!--[gt text='hello']-->anything in between <!--[gt text='apple' plural="apples" count=2]-->

<!--[gt text="hello %s" tag="name"]--> more stuff<!--[gt plural="apples for %s" text='apple for %s' tag='you' html=1 count=2]-->more text and maybe some html etc.


should become:

<?php g('hello'); ?>anything in between <?php ng('apple', 'apples', 2); ?>

<?php g('hello %s'); ?> more stuff<?php ng('apple for %s', 'apples for %s', 2); ?>more text and maybe some html etc.

Notice that the order when we translate is important for plurals, because we replace in the form ng(text, plural, count) even if the order was mixed up. Notice how we disregard all the other possible params.

The solution must be either a php script, perl script or shell script. Just needs to be able to read a file and output the file... nothing fancy and no interface at all. if writing in a PHP script just file_get_contents and file_put_contents is enough.

Please note that the params may contain quotations marks and so on.


text='hello to "you" today'
text="hello to 'you' today"
text='hello to 'you' today'

So the regex or whatever needs to be aware of this and other special characters that may appear.

Taidot: Perl, PHP

Näytä lisää: up string, translate quotes, text string search, string search in c, string pattern, some search string, search text string, search string in c, search string c, search string, search for solution, search c string, perl search script, pattern strings, pattern string, c text search, c string search, c string pattern, c search string, example shell script, double words, basic shell script, fancy writing, search file, replace

Tietoa työnantajasta:
( 1 arvostelu ) Roseay, Dominica

Projektin tunnus: #482631

Myönnetty käyttäjälle:


check pm please

$80 USD 1 päivässä
(284 Arvostelua)

12 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön


Hi, Please see PMB. Thanks, Dharmendra

$60 USD 1 päivässä
(40 arvostelua)

Can do it easily , have loads of experience with regex, string matching stuff .

$40 USD 0 päivässä
(8 arvostelua)

Hi, please check the PM.

$60 USD 1 päivässä
(4 arvostelua)

please check your pm.

$30 USD 1 päivässä
(3 arvostelua)

i already did two projects in perl,it's easy ,let's start

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

i have long experience for these. lets start with me i will give you this work with in one day

$65 USD 1 päivässä
(0 arvostelua)

Hi. I can do it with perl.

$30 USD 1 päivässä
(0 arvostelua)

I am interested to your project. I am a Web Developer with extensive experience PERL I have 8 years of experience in software design and development web-based cross-browser and cross-platform systems. Thanks

$75 USD 1 päivässä
(0 arvostelua)

I am very much comfortable with Perl. So i think i can complete this within 1 day [login to view URL] since i need to test it aganist various testcase i need half day more.

$30 USD 2 päivässä
(0 arvostelua)

I am very much familiar with perl. Having 8 years experience in perl. Good in regular expression. Having experience in perl/cgi, mod_perl based web applications. I will complete this work within a day.

$70 USD 1 päivässä
(0 arvostelua)

Let's start to save time.

$60 USD 3 päivässä
(0 arvostelua)