Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Extract the first word (before the , )

Posted on 2016-11-29
2
54 Views
Last Modified: 2016-11-29
Hi All,

I need to extract from a list below only the first word. Data is a little tricky, in few lines, there is no space after the first comma. Using Oracle 11g.

BOLT, ELEVATOR: 5/16", 2"LG, UNC, BLACK, 100
CAPSCREW, SOCKET HEAD: 10-32, 3/8"LG, 8, FLAT, PKG QTY = 100
CAPSCREW, SOCKET HEAD: 10-32, 1"LG, PLATED, 8, FLAT, 100
CAPSCREW,SOCKET HEAD: 1/4", 28, 1/2"LG, PLATED, 8, FLAT, 100
CAPSCREW,FLAT SOCKET HEAD:1/4"-28, 3/4"LG, GR8,COUNTERSUNK, PKG QTY = 100
SCREW,SHEET METAL: #10 X 3/8", PLATED, BINDING, ROBERTSON, GIMLET POINT, PKG QT

Thanks
0
Comment
Question by:mohammadzahid
2 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41906604
Try regular expression

Regexp_substr(line, '\w[^,]', 1, 1)
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 41906605
Try this:
select regexp_substr(some_column,'^[^,]*') from some_table;
or
select substr(some_column,1,instr(some_column,',')-1) from some_table;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help on model clause 5 37
add more rows to hierarchy 3 25
join actual table rows based on the column 25 21
format dd/mm/yyyy parameter 16 30
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question