0
$\begingroup$

I am trying to replace quotation marks of a tex file " " to `` ''. With a small file, I tried

Clear["Global`*"] SetDirectory[NotebookDirectory[]]; latexContent = " \\documentclass{article} \\begin{document} ''Hello, world!'' said the computer. ''This is a test document.'' \ Please review it. \\end{document} "; latexContent = StringReplace[latexContent, RegularExpression["(^|\\s)('')"] -> "$1`"]; latexContent = StringReplace[latexContent, "''" -> "''"] 

I get

enter image description here

If I have a tex file put in the folder D:\myfolder\main.tex". How can I change all quotation marks of this file?

\item 279. Nor is it good for parents to be domineering. When children are made to feel that only their parents can be trusted, this hinders an adequate process of socialization and growth in affective maturity. To help expand the parental relationship to broader realities, "Christian communities are called to offer support to the educational mission of families", \footnote{Catechesis (20 May 2015): L'Osservatore Romano, 21 May 2015, p. 8.} particularly through the catechesis associated with Christian initiation. To foster an integral education, we need to "renew the covenant between the family and the Christian community". \footnote{Catechesis (9 September 2015): L'Osservatore Romano, 10 September 2015, p. 8.} The Synod wanted to emphasize the importance of Catholic schools which "play a vital role in assisting parents in their duty to raise their children... Catholic schools should be encouraged in their mission to help pupils grow into mature adults who can view the world with the love of Jesus and who can understand life as a call to serve God". \footnote{Relatio Finalis 2015, 68.} For this reason, "the Church strongly affirms her freedom to set forth her teaching and the right of conscientious objection on the part of educators" \footnote{Ibid., 58} \item 280. The Second Vatican Council spoke of the need for "a positive and prudent sex education" to be imparted to children and adolescents "as they grow older", with "due weight being given to the advances in the psychological, pedogogical and didactic sciences", \footnote{Second Vatican Ecumenical Council, Declaration on Christian Education Gravissimum Educationis, 1.} We may well ask ourselves if our educational institutions have taken up this challenge. It is not easy to approach the issue of sex education in an age when sexuality tends to be trivialized and impoverished. It can only be seen within the broader framework of an education for love, for mutual self-giving. In such a way, the language of sexuality would not be sadly impoverished but illuminated and enriched. The sexual urge can be directed through a process of growth in self-knowledge and selfcontrol capable of nurturing valuable capacities for joy and for loving encounter.\\ \item 281. Sex education should provide information while keeping in mind that children and young people have not yet attained full maturity. The information has to come at a proper time and in a way suited to their age. It is not helpful to overwhelm them with data without also helping them to develop a critical sense in dealing with the onslaught of new ideas and suggestions, the flood of pornography and the overload of stimuli that can deform sexuality. Young people need to realize that they are bombarded by messages that are not beneficial for their growth towards maturity. They should be helped to recognize and to seek out positive influences, while shunning the things that cripple their capacity for love. We also have to realize that "a new and more appropriate language" is needed "in introducing children and adolescents to the topic of sexuality". \footnote{Relatio Finalis 2015, 56.} 
$\endgroup$
3
  • $\begingroup$ Try: latexContent = Import[nam, "Text"]; StringReplace[latexContent, RegularExpression["(^|\\s)('')"] -> "$1`"] $\endgroup$ Commented Jan 28 at 9:52
  • $\begingroup$ Did you intentionally want opening quotes to be single and closing quotes to be double, or is that an error in your code? $\endgroup$ Commented Feb 5 at 22:06
  • $\begingroup$ Is your question really about how to overwrite a file with new content? Based on the title of your question, I can't tell whether you're still struggling with getting the StringReplace code right, or if you're struggling to import the file, or if you're struggling to write out the new string to a file. $\endgroup$ Commented Feb 5 at 22:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.