On Apr 21, 2013, at 09:03, Kevin Ingwersen <
ingwi...@googlemail.com> wrote:
> So I got a very long file with informations and tasks, and the guy formated the file using a css-like syntax:
______________________________________________________________________
Hey Kevin,
Please note that when asking for help with this sort of thing it's much better to offer as real a data sample as possible. It usually saves time and trouble.
From what you describe your task is possible with regex find/replace, but it would appear to be much easier to use a Text Filter.
As you'll see below this filter just cleans up the formatting of the tasks a bit using sequential regex find/replace.
From there it's really simple to get rid of braces and brackets and change the formatting.
Your TextWrangler text filters folder should be here:
~/Library/Application Support/TextWrangler/Text Filters/
If it's not then create it.
Save the text filter below as a file in that folder.
Apply it from the {MENU-BAR} --> {Text} --> {Apply Text Filter} --> {Your Filter Name}
--
Best Regards,
Chris
#-------------------------------------------------------------------------------------------
# TEXT FILTER
#-------------------------------------------------------------------------------------------
#! /usr/bin/env perl -0777 -n
use v5.12; use strict; use warnings;
#---------------------------------------
s!\s*\{\s*!\n{!gi;
s!\s*\}\s*!}!gi;
s!\s*\[\s*!\n[!gi;
s!\s*\]!]!gi;
print;
#-------------------------------------------------------------------------------------------
# TEST DATA
#-------------------------------------------------------------------------------------------
Task Name 1 {
Study JFK Speech.
} [
"Now is the time for all good men to come to the aid of their country."
]
Task_Name_2 {
More Contents
} [ Info ]
Task_Name_3 {
An unwrapped study of Lorem Ipsum.
} [
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
]
Task Name 4 {
A compressed study of Lorem Ipsum.
} [
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
]
#-------------------------------------------------------------------------------------------
# RESULT
#-------------------------------------------------------------------------------------------
Task Name 1
{Study JFK Speech.}
["Now is the time for all good men to come to the aid of their country."]
Task_Name_2
{More Contents}
[Info]
Task_Name_3
{An unwrapped study of Lorem Ipsum.}
[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]
Task Name 4
{A compressed study of Lorem Ipsum.}
[Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.]
#-------------------------------------------------------------------------------------------