• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems while parsing files in different encoding

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, thanks. I'm so dummy

the character is : \p{L}

Tanks for help:thumbup:
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, that looks familiar.
reply
    Bookmark Topic Watch Topic
  • New Topic