Skip to content

Conversation

@yurii-sio2
Copy link
Contributor

Description

The current regex causes the loss of the original formatting of some documents after the variables have been overwritten.
Replaces the current regex with one that resolves this problem.
New regex from @brainwood
/\$(?:\{|[^{$]*\>\{)[^}$]*\}/U

The brainwood's pull request was rejected due to pipe regex delimiters "|"

Fixes #1345

Example:

We have the text
$15000. ${variable_name}

That breaks down to the following xml:

<w:t>$</w:t></w:r><w:bookmarkStart w:id="0" w:name="_GoBack"/><w:bookmarkEnd w:id="0"/><w:r><w:t xml:space="preserve">15,000.00. </w:t></w:r><w:r w:rsidR="0056499B"><w:t>$</w:t></w:r><w:r w:rsidR="00573DFD" w:rsidRPr="00573DFD"><w:rPr><w:iCs/></w:rPr><w:t>{</w:t></w:r><w:proofErr w:type="spellStart"/><w:r w:rsidR="00573DFD" w:rsidRPr="00573DFD"><w:rPr><w:iCs/></w:rPr><w:t>variable_name</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r w:rsidR="00573DFD" w:rsidRPr="00573DFD"><w:rPr><w:iCs/></w:rPr><w:t>}</w:t></w:r>

The current regex and yours would pars the $15000. ${variable_name} as the variable where it should just be ${variable_name}

The current regex causes the loss of the original formatting of some documents after the variables have been overwritten.
Replaces the current regex with one that resolves this problem.
New regex from @brainwood
/\$(?:\{|[^{$]*\>\{)[^}$]*\}/U

The brainwood's pull request was rejected due to pipe regex delimiters "|"
@coveralls
Copy link

coveralls commented Nov 8, 2018

Coverage Status

Coverage decreased (-0.001%) to 94.677% when pulling 927aae5 on yurii-sio2:fix_TemplateProcessor into af5a271 on PHPOffice:develop.

@troosan troosan added this to the v0.16.0 milestone Dec 7, 2018
@troosan troosan merged commit 260bb75 into PHPOffice:develop Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants