Solved

Extract the first word (before the , )

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

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.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

708 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