0

I want to be more efficient and save some time when coding. Here is the idea which I do not know any solution to: (Note: I am a beginner and I am open to any programming languages you suggest.)

Let´s assume we have a text data. I have special chars at the beginning and at the end of a keyword. Firstly I need to parse the text data and then insert them into another text file.

For example like this: I have a certain text

$method1$
§text1§
$method2$
§text2§

the text between the chars $$(here method1 and method2) and the text between §...§(here text1 and text2) would be found by the program and then inserted into a template:

method1() { print.text1};
method2() { print.text2};

Does such program already exist? If not I really have no idea how to approach making one. I appreciate every hint and help.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83

1 Answers1

0

You can easily make this with a programming language I believe. Really, you can use any language you like. I prefer Ruby to do this, but Perl is also great for parsing this type of thing. It would be great if you could give us a sample of the actual file you will be parsing. Really, programming language choice is up to you, and whichever you choose you can google "regular expressions" and the name of the language to figure out how to do it.

If you did Ruby you can do something like this:

text.scan(/^\s*$\s/)

Ruby reference:

Parsing text in Ruby

Parsing strings and regular expressions in Perl (good tutorial)

http://perldoc.perl.org/perlretut.html

Community
  • 1
  • 1
camdixon
  • 852
  • 2
  • 18
  • 33