Programmer_n
09-06-2017, 07:04 AM
This task is about spacing around punctuation
For example:
The code below adds a spacing next to the period.
sentence :This is a sample sentence .This sentence is alright.
sentence :This is a sample sentence. This sentence is alright.
ActiveDocument.Range.Find.Execute FindText:="([A-Za-z]\.)([A-Za-z])", _
MatchWildcards:=True, Wrap:=wdFindContinue, Replacewith:="\1 \2", _
Replace:=wdReplaceAll
Case 1:
What if the period is attached to the next word.
sentence :This is a sample sentence .This sentence is alright.
expected result: This is a sample sentence. This sentence is alright.
Case 2:
What if there needs to be spaces on either side of the period.
This is a sample sentence.This sentence is alright.
This is a sample sentence . This sentence is alright.
Case 3: what if i need to trim spaces on either side.
This is a sample - sentence.
This is a sample-sentence.
Please ignore abbreviations or units that contain period and let's assume only end sentence period is present around the document.
Please help.
For example:
The code below adds a spacing next to the period.
sentence :This is a sample sentence .This sentence is alright.
sentence :This is a sample sentence. This sentence is alright.
ActiveDocument.Range.Find.Execute FindText:="([A-Za-z]\.)([A-Za-z])", _
MatchWildcards:=True, Wrap:=wdFindContinue, Replacewith:="\1 \2", _
Replace:=wdReplaceAll
Case 1:
What if the period is attached to the next word.
sentence :This is a sample sentence .This sentence is alright.
expected result: This is a sample sentence. This sentence is alright.
Case 2:
What if there needs to be spaces on either side of the period.
This is a sample sentence.This sentence is alright.
This is a sample sentence . This sentence is alright.
Case 3: what if i need to trim spaces on either side.
This is a sample - sentence.
This is a sample-sentence.
Please ignore abbreviations or units that contain period and let's assume only end sentence period is present around the document.
Please help.