jEdit Community - Resources for users of the jEdit Text Editor
Help needed for regular expression replace
Submitted by bagazsi on Thursday, 1 February, 2007 - 12:35
I should like to manipulate text files containing several TITLE lines. The format of title is: TITLE "" I have to add a few number of new text rows after all title lines. I've tried it with Regular expression replace. The search for line is TITLE " the Replace with is TITLE "$1 addition of new text I've got the following error message: Sourced file: inline evaluation of: ``__internal_replace(ns) { this.callstack.set(0,ns); return ( TITLE "$1 add . . . '' Token Parsing Error: Lexical error at line 3, column 22. Encountered: "\n" (10), after : "\"$1": Could anybody help me with the right syntax, or have a good idea to solve my problem? Thanks in advance, Gaspar
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Sample?
by elberry on Thu, 01/02/2007 - 15:45
Could you post an example of what the files look like, and how you want them to look?

eg.
[actual]
TITLE "This is my title"
The rest of the file content goes here.
[/actual]

[desired]
TITLE "This is my title"


The rest of the file content goes here.
[/desired]

Thanks, I think that'll help.


Learn from the past. Live in the present. Plan for the future.
 
An example as required
by bagazsi on Fri, 02/02/2007 - 10:08
actual:

DISC_ID "D1115811"
TITLE "Brahms - Symphonies"
FILE "Brahms Symphonies-Furtwängler - D1.flac" WAVE
TRACK 01 AUDIO
TITLE "Ungarische Tänze-1. G minor (Allegro molto)"
INDEX 00 00:00:00
INDEX 01 00:00:33
TRACK 02 AUDIO
TITLE "Ungarische Tänze-3. F major (Allegretto)"
INDEX 00 03:05:60
INDEX 01 03:05:63
...

desired:
DISC_ID "D1115811"
TITLE "Brahms - Symphonies"
FILE "Brahms Symphonies-Furtwängler - D1.flac" WAVE
TRACK 01 AUDIO
TITLE "Ungarische Tänze-1. G minor (Allegro molto)"
GENRE "Classical"
YEAR "1949"
COMPOSER "Brahms"
CONDUCTOR "Furtwängler"
BAND "Wiener Philharmoniker"
INDEX 00 00:00:00
INDEX 01 00:00:33
TRACK 02 AUDIO
TITLE "Ungarische Tänze-3. F major (Allegretto)"
GENRE "Classical"
YEAR "1949"
COMPOSER "Brahms"
CONDUCTOR "Furtwängler"
BAND "Wiener Philharmoniker"
INDEX 00 03:05:60
INDEX 01 03:05:63
...

As you see, I must insert the same GENRE, YEAR, COMPOSER, CONDUCTOR and BAND lines after every TITLE. The file is and must have UTF-8 encoding.

Regards,
Gaspar
 
Maybe.
by elberry on Fri, 02/02/2007 - 15:31
Ok. Well, you could use this regex in the Search and Replace dialog.

[regex]
^(TITLE\s\"[^\"]+\")$
[/regex]

That should find you all the title lines.

You could then replace them with:

[replace]
$1\nGENRE "Classical"\nYEAR "1949"\nCOMPOSER "Brahms"\nCONDUCTOR "Furtwängler"\nBAND "Wiener Philharmoniker"
[/replace]

Hope that helps.


Learn from the past. Live in the present. Plan for the future.
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293