Solved

Extract the first word (before the , )

Posted on 2016-11-29
2
39 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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now