Insert characters into string based on re ?
Frederic Rentsch
anthra.norell at vtxmail.ch
Sun Oct 15 02:30:51 EDT 2006
Frederic Rentsch wrote:
> Matt wrote:
>> I am attempting to reformat a string, inserting newlines before certain
>> phrases. For example, in formatting SQL, I want to start a new line at
>> each JOIN condition. Noting that strings are immutable, I thought it
>> best to spllit the string at the key points, then join with '\n'.
>>
>> Regexps can seem the best way to identify the points in the string
>> ('LEFT.*JOIN' to cover 'LEFT OUTER JOIN' and 'LEFT JOIN'), since I need
>> to identify multiple locationg in the string. However, the re.split
>> method returns the list without the split phrases, and re.findall does
>> not seem useful for this operation.
>>
>> Suggestions?
>>
>>
>
> Matt,
>
> You may want to try this solution:
>
> >>> import SE
... snip
>
> http://cheeseshop.python.org/pypi?:action=display&name=SE&version=2.3
For reasons unknown, the new download for SE is on the old page:
http://cheeseshop.python.org/pypi/SE/2.2%20beta.
>
>
> Frederic
>
>
> ----------------------------------------------------------------------------------------------------------------------
More information about the Python-list
mailing list