Text parsing and substitution
- From: maheshpop1@xxxxxxxxx
- Date: 19 May 2006 03:17:22 -0700
Hi guys,
I am doing this module where I am gonna change the following sentence
"1:action=commit:user=joe:date=2005-02-02:"
"2:action=checkout:user=mark:date=2005-02-03:"
to something like
" 1. Commits by user Joe on date 2005-02-02 "
" 2. Checkouts by user Joe on date 2005-02-03"
making the above text a little bit more readable to the user. I started
of with a program which finds out the different key value pairs and
and based on the values append/create a string with approriate words
like
pseudocode only
parse the line,
load a hashmap with the key, value pairs
if(hash{action}=='commit') <---this is a mandatory field
string.="Commits"
if(defined hash{user})
string.="by hash{user})
if(defined hash{date})
string.="on date hash{date}"
...................................
...................................
if(hash{action}=='checkout') <---this is a mandatory field
string.="Commits"
if(defined hash{user})
string.="by hash{user})
if(defined hash{date})
string.="on date hash{date}"
..............................................
.............................................
I was thinking this sort of logic but a little apprehensive how elastic
it can be as I would be addressing so many actions and seperate if
blocks for all of them. Any suggestions or ideas on how to better
achieve what I want to do above.
cheers,
pop.
.
- Follow-Ups:
- Re: Text parsing and substitution
- From: Dr.Ruud
- Re: Text parsing and substitution
- From: Tad McClellan
- Re: Text parsing and substitution
- From: corff
- Re: Text parsing and substitution
- Prev by Date: Re: Use of initialized value in pattern match
- Next by Date: Re: printing css
- Previous by thread: Calling functions by name and load modules on demand
- Next by thread: Re: Text parsing and substitution
- Index(es):
Relevant Pages
|