Need better string methods

William Park opengeometry at yahoo.ca
Sat Mar 6 17:50:25 EST 2004


Christian Tismer <tismer at stackless.com> wrote:
> William Park wrote:
> > Both Bash shell and Python can split based on regular expression.
> > However, shell is not a bad alternative here:
> >     tr -s ' \t' ' ' | sed -e 's/ ?| ?/|/g' -e 's/^ //' -e 's/ $//' |
> >     while IFS='|' read -a clean; do
> >       ...
> >     done
> 
> But isn't that regex expression much harder to understand
> for part-time programmers than the few Python methods?

But, OP's audience is not part-time programmers.  My guess is that they
immediately abandon shell and jump to proprietary languages.  OP may
have better luck if they stick with shell a bit longer, and then jump to
Python as last resort.  

As for regex... it's usually easier to set up the data to be cut,
instead of cutting first and then patching up the pieces.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data processing and document management.



More information about the Python-list mailing list