Skip to content

Conversation

@yurii-sio2
Copy link
Owner

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 PHPOffice#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 "|"
@yurii-sio2 yurii-sio2 merged commit 3786fd0 into develop Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants