[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regular Expressions

Wayne Landsman wrote:

> P.S. The real-life problem I am working on deals not with 'l' but with
> apostrophes.   I am trying to speed up the processing of FITS header
> values, where is a string is delineated by non-repeating apostrophes, and a
> possessive is indicated by a double apostrophe.
> VALUE = 'This is Wayne''s FITS value' / Example string field

how about:

IDL> value= "VALUE = 'This is Wayne''s FITS value' / A FITS COMMENT"
IDL> print,(stregex(value,/SUBEXPR,/EXTRACT,"= *'(.*)'([^']|$)"))[1]

You will always have something before the initial "'" in the full header

You can then change double quotes to single quotes in the usual way with
a strpos loop.