Regular expressions - matching strings

S

sconeek

hi all,
i am working on a java application. i have this table which contains
name fields and all of them start with a N-. so the table contains
records like N-TomSmith, N-PeterSay etc.
now from within my java class i am trying to read these records.
now the main bit, how should i specify my class to pick up all records
which start with N-.
am trying to read about reg expressions in the meantime. i hope
somebody can help me.
thanks.
 
K

Knute Johnson

hi all,
i am working on a java application. i have this table which contains
name fields and all of them start with a N-. so the table contains
records like N-TomSmith, N-PeterSay etc.
now from within my java class i am trying to read these records.
now the main bit, how should i specify my class to pick up all records
which start with N-.
am trying to read about reg expressions in the meantime. i hope
somebody can help me.
thanks.

Have you split them into strings? If so you can check the first
characters with String.startsWith().
 
R

Roedy Green

i am working on a java application. i have this table which contains
name fields and all of them start with a N-. so the table contains
records like N-TomSmith, N-PeterSay etc.
now from within my java class i am trying to read these records.
now the main bit, how should i specify my class to pick up all records
which start with N-.
am trying to read about reg expressions in the meantime. i hope
somebody can help me.

field.charAt(0) == 'N' && field.charAt(1) == '-'
or
field.startsWith( "N-" )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top