473,841 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex matching 3rd word in a line?

I'm looking to match the 3rd (or whatever) word in a line, where word
can be anything that's not white space.

I'm not programming, but I'm using a program which says it uses python
style regular expressions.

Jul 18 '05 #1
3 18639
Ian Gil wrote:
I'm looking to match the 3rd (or whatever) word in a line, where word
can be anything that's not white space.

I'm not programming, but I'm using a program which says it uses python
style regular expressions.

This will match the third word in a line:

^(?:\S+\s){2}(\ S+)

Change the "2" to "whatever - 1" to match a different word.


Jul 18 '05 #2
>> I'm looking to match the 3rd (or whatever) word in a line, where word
can be anything that's not white space.

I'm not programming, but I'm using a program which says it uses python
style regular expressions.

This will match the third word in a line:

^(?:\S+\s){2}(\ S+)

Change the "2" to "whatever - 1" to match a different word.

This worked except it's matching from the beginning up to the third word
and I'm looking to match just the third word. I tried some variations of
it but apparently not the right ones.


Jul 18 '05 #3
Ian Gil wrote:
and I'm looking to match just the third word.

Hm, first extract the third word and then use re?
s = "one two three four"


split has an optional argument "sep" to define other chars than
whitespace characters.

Gruß - regards
Klaus :-)

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Merlin | last post by:
Hello, I am trying to find out how to create a line of JS code to do a regex to match a URL inside a text. I don't want to know if it is valid, but just if there is a URL inside a text. Can anybody give me quick start on how I can acchive this? I surfed a couple of regex sites, but could not find a solution so far. Thank you in advance.
by: Bob | last post by:
I think this is very simple but I am having difficult doing it. Basically take a comma separated list: abc, def, ghi, jk A list with only one token does not have any commas: abc The first letter of each token (abc) must not be a number. I am simply trying to parse it to get an array of tokens: abc
by: George Durzi | last post by:
Consider this excerpt from some HTML. (This is a copy from View->Source, except for the comment) <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 border=0> <?xml version="1.0" encoding="UTF-16"?> <!-- need to extract whatever is here --> </TABLE> I need to extract all the HTML that would be in the <!-- need to extract whatever is here --> section. So I did the following.
by: Dan Hargrove | last post by:
I'm using the regex class to try and search a string for line feeds, carriage returns, and tabs. In a windows test app, I can enter the expression of \\ and this works fine. But in the ASP.net app, the same expression does not work, even though the same process and test strings are being used. Here's the set of code to test this process on the ASP.net page that I'm using: string strExpression = @"\\";...
by: Tidane | last post by:
Visual Basic.NET Framework 2.0 I've created a program to parse out text as the program recieved it and use Regex matching to decide what should be done. My problem is that the text is matching when it shouldn't be, if that makes any sense. If Regex.IsMatch(Text, "You find (a|an)" & MoneyMatch) Then Other code here that doesn't matter. ElseIf Regex.IsMatch(Text, "(+\s)obtains (a|an)") Then More code that doesn't matter. EndIf
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 i.e. 6 comma-delimited pairs of integer numbers separated by the
by: jwwest | last post by:
Anyone have any trouble pattern matching on lines returned by readline? Here's an example: string = "Accounting - General" pat = ".+\s-" Should match on "Accounting -". However, if I read that string in from a file it will not match. In fact, I can't get anything to match except ".*".
by: jagged | last post by:
I'm new to C# so am not completely familiar with its regular expression flavor and I don't understand why I can't get this to work. I set the singline | ignorecase options in the regex ctor. Given the following example data <tr>test1:567.98 </tr> <tr>test1:567.98 test2:999 </tr> <tr>test1:267.98 test2:959 </tr> <tr>test1:547.98 test2:699 </tr> <tr>test1:567.98 </tr>
by: saravanakumar muthurangan | last post by:
Hello all, i need to correct a misspelled word automatically with a most matching word by using MS word.dll in vb.net 2005, i m getting the checkspelling window with the below code but i need the word has to be corrected without asking for suggestions................... Can any one help me on this.................... Imports word = Microsoft.Office.Interop.Word Dim word_server As New word.Application ...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.