Changeset 11296


Ignore:
Timestamp:
2006-03-01T15:29:35+13:00 (18 years ago)
Author:
kjdon
Message:

now only use a-z1-9 chars in the index names (\w) in case the names have unicode chars in them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/basebuilder.pm

    r10482 r11296  
    453453# of that componant - otherwise it will contain the first
    454454# character of the first two components
     455# only uses letdig (\w) characters now
    455456sub process_field {
    456457    my $self = shift (@_);
    457458    my ($field) = @_;
    458  
    459     return "" unless (defined ($field) && $field =~ /\w/);
    460 
     459
     460    return "" unless (defined ($field) && $field =~ /\S/);
     461   
     462    my ($a, $b);
    461463    my @components = split /,/, $field;
    462464    if (scalar @components >= 2) {
    463     splice (@components, 2);
    464     map {s/^(.).*$/$1/;} @components;
    465     return join("", @components);
     465    # pick the first letdig from the first two field names
     466    ($a) = $components[0] =~ /^[^\w]*(\w)/;
     467    ($b) = $components[1] =~ /^[^\w]*(\w)/;
    466468    } else {
    467     my ($a, $b) = $field =~ /^(.).*?([bcdfghjklmnpqrstvwxyz])/i;
    468     ($a, $b) = $field =~ /^(.)(.)/ unless defined $a && defined $b;
    469     return "$a$b";
    470     }
     469    # pick the first two letdig chars
     470    ($a, $b) = $field =~ /^[^\w]*(\w)[^\w]*?(\w)/i;
     471    }
     472    # there may not have been any letdigs...
     473    $a = 'a' unless defined $a;
     474    $b = '0' unless defined $b;
     475
     476    return "$a$b";
     477   
    471478}
    472479
Note: See TracChangeset for help on using the changeset viewer.