开发者

regular expression to find in-between content

I am trying to find the content between %%EndPageSetup and LH(%%[Page: 1]%%) = using regular expression. I tried various patterns but not getting the correct output. Can someone please help me on this?

%EndPageSetup

/DeviceGray dup setcolorspace /colspABC exch def ‹ … scol … „A VM? Pscript_WinNT_Incr begin %%BeginResource: file Pscript_T42Hdr 5.0 0 /asc42 0.0 d/sF42{/asc42 ~ d Ji}bind d/bS42{0 asc42 -M}bind d/eS42{0 asc42 neg -M}b/Is2015?{version cvi 2015 ge}bind d/AllocGlyphStorage{Is2015?{!}{{string} forall}?}bind d/Type42DictBegin{25 dict /FontName ~ d/Encoding ~ d 4 array astore cvx/FontBBox ~ d/PaintType 0 d/FontType 42 d/Fo开发者_JAVA百科ntMatrix[1 0 0 1 0 0]d /CharStrings 256 dict/.notdef 0 d & E d/sfnts}bind d/Type42DictEnd{& @ /FontName get ~ definefont ! E}bind d/RDS{string currentfile ~ readstring !} executeonly d/PrepFor2015{Is2015?{/GlyphDirectory 16 dict d sfnts 0 get @ 2 ^ (glyx)putinterval 2 ^(locx)putinterval ! !}{! !}?}bind d/AddT42Char{Is2015? {findfont/GlyphDirectory get ` d E ! !}{findfont/sfnts get 4 ^ get 3 ^ 2 ^

LH(%%[Page: 1]%%) =

Thanks.


this may work

/EndPageSetup(.*?)LH\((?:.*?)\[Page: 1\](?:.*?)\) =/


This works with your examples

%%EndPageSetup(.*?)\(%%\[.*?Page.*?\]%%\) =

See it here online on Regexr

make sure to activate the s (dotall) modifier, so that is possible to match newline characters with the ..

Your result is then in capture group 1.

How to activate the modifier and how to get the result depends on your language.


This should work:

(?:%%EndPageSetup)(.*\n)*(?=LH\(%%\[Page: 1\]%%\) =)

Explanation

  • The 3rd capture group (?=LH\(%%\[Page: 1\]%%\) =) uses a positive lookahead, so you can match that group without including it in the result.

  • The 2nd capture group (.*\n) matches all characters including line breaks. Using *, you can match 0 or more of the preceding token/group.

  • The first non-capturing group matches (?:%%EndPageSetup)and omits it from the result.

Note

You can use lookbehinds too, but JavaScript doesn't support them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜