Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems while parsing files in different encoding

 
Jan Kwiatkowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

If You want, please help me with the following:

A have a test.txt file, with single line:

Caption = Rückwärt Caption = Vorwärts Caption = Vorwärts

As you can see there are some Unicode characters like "ü"

With the following program:



I would like to display pairs (using regexp):
Caption = smth

but the output is:

Caption = &R
Caption = &Vorw
Caption = &Vorw

Those unicode characters don't won't to be printed, so as the rest of the letters after them

However this program (with no regexp, only printing this one line from the file):



prints fine:

Caption = &Rückwärt Caption = &Vorwärts Caption = &Vorwärts

It seems to be some problems with regexp's mechanism.

Could You please write what I'm doing wrong?
 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Kwiatkowski wrote:As you can see there are some Unicode characters like "ü"

... which are obviously not in either of the ranges "a-z" or "A-Z'. But that's what you selected. So you excluded those characters.

There's a special code in regex which means "any Unicode letter". I don't remember what it is but you could look it up in your regex reference.
 
Jan Kwiatkowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks. I'm so dummy

the character is : \p{L}

Tanks for help
 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, that looks familiar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic