473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to convert *.tex files to plain text *.txt

I don't know where to start for this but I've been looking around and asking and I think i'm supposed to use tokenizers.

The rules I have to follow are:
1. Remove all commands backslash followed one or more lowercase letters and terminated with a blank.
2. Remove all braces: } or {.
3. Substitute all math display (characters in between $), by the words FORMULA 1
, FORMULA 2 etc...
4. The environment ( a special command) .
\begin{enumerate}
\item First item, \fer and only this.
\item Second line \iterate and maybe more. \item Third.
...
\end{enumerate}
puts everything between backslash item in a new paragraph with a number. So the
above should look:
1. First item and only this.
2. Second line and maybe more.
3. Third.
Jan 20 '17 #1
1 1191
chaarmann
785 Expert 512MB
You can also use regular expressions. This would be much easier.
For example, replacing curly brackets and mathematical expressions:

Expand|Select|Wrap|Line Numbers
  1. String input = "asdf{{xx{fd}$3*7+5$ab";
  2. String regEx = "[\\{\\}]";
  3. String result = input.replaceAll(regEx, "");
  4. // result = "asdfxxfd$3*7+5$ab"
  5.  
  6. String regEx = "\\$[^\\$]*?\\$";
  7. String result2 = result.replaceAll(regEx, "FORMULA");
  8. // result2 = "asdfxxfd$FORMULA$ab"
Jan 23 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
58
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split...
1
by: rob.kellington at gmail | last post by:
Does anyone have the logic to convert RTF formatted data in a text column into plain ascii text that I can use in a varchar variable or field? We have an app that allows formatted comments/notes...
4
by: Zephyr . via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Zephyr . hey, i got trouble getting integers out of a plain text file. i dont want to use binary files, just plain text files...
8
by: Doominato | last post by:
good day, I was just wondering how can I download a web page as plain text from a certain web site. I have tried to use the OpenURL() method from INET control in my VB.NET app, but it returns...
10
by: Eric Lindsay | last post by:
This may be too far off topic, however I was looking at this page http://www.hixie.ch/advocacy/xhtml about XHTML problems by Ian Hickson. It is served as text/plain, according to Firefox...
1
by: Harish | last post by:
Hi Please let me know how i can convert the word document into text file. In this i am uploading a word document in web application and want to convert it into text file. Thanks, Harish
0
by: Shat T. Cat | last post by:
Hello, I have a program that I originally wrote in VB6 that breaks down plain-text Profit & Loss reports from my organization's Accounting system into separate files for each Cost Center (office...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
7
by: sudhagowda | last post by:
Hi, I want to convert pdf to text content in db. While insert pdf file to database before save it will will convert pdf to text content. I have to use pdf2text.class also but not converting. ples...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.