Click here to Skip to main content
14,971,553 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
AnswerRe: Replace certain characters in part of string? Pin
Richard Deeming22-Mar-21 2:08
mveRichard Deeming22-Mar-21 2:08 
GeneralRe: Replace certain characters in part of string? Pin
w 3g22-Mar-21 23:38
Memberw 3g22-Mar-21 23:38 
GeneralRe: Replace certain characters in part of string? Pin
Richard Deeming22-Mar-21 23:49
mveRichard Deeming22-Mar-21 23:49 
GeneralRe: Replace certain characters in part of string? Pin
w 3g23-Mar-21 0:21
Memberw 3g23-Mar-21 0:21 
QuestionRegex only want the first match Pin
Member 150872251-Mar-21 11:04
MemberMember 150872251-Mar-21 11:04 
AnswerRe: Regex only want the first match Pin
Aghast (nj)9-Mar-21 17:53
MemberAghast (nj)9-Mar-21 17:53 
Questionregex pattern in order to get a list of numbers from a string Pin
Rafael Soteldo17-Feb-21 4:48
MemberRafael Soteldo17-Feb-21 4:48 
AnswerRe: regex pattern in order to get a list of numbers from a string Pin
Aghast (nj)9-Mar-21 17:51
MemberAghast (nj)9-Mar-21 17:51 
You don't say what environment you are working in, so it's hard to give you useful code.

However, you can probably get what you want by either doing a search & replace operation, possibly repeated, or by using some kind of "regex iterator" approach.

For C++, it would be a regex iterator (iterate over all the matches of THIS pattern in THAT string). For something like Python it would be find all occurrences of THIS pattern in THAT string.

In order to drop the "8;" from your example sentence, you'd want to provide a better pattern than just "some digits." Instead, use something like /(\d+):/ to match on one-or-more digits followed by a colon. You want to capture the digits, not the colon.

If you can just iterate over all matches in the string, that will probably be enough. If you're doing sed or some other editor, you'll have to search and replace the line. If possible, see if you can do something like a non-greedy match (.*?) to match all the text between matches, and then replace it with a comma. (FYI: The ? operator is a non-greedy modifier in Perl-style regex engines. Other regex engines may not support this at all, or they may have a different syntax-- for example, Vim would use .\{-} for that.
QuestionString Replacement in 'HTML 5 FireFox' Pin
Member 1357268429-Dec-20 0:47
MemberMember 1357268429-Dec-20 0:47 
AnswerRe: String Replacement in 'HTML 5 FireFox' Pin
OriginalGriff29-Dec-20 0:54
mveOriginalGriff29-Dec-20 0:54 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268429-Dec-20 1:04
MemberMember 1357268429-Dec-20 1:04 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
OriginalGriff29-Dec-20 1:39
mveOriginalGriff29-Dec-20 1:39 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268429-Dec-20 1:51
MemberMember 1357268429-Dec-20 1:51 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
OriginalGriff29-Dec-20 2:23
mveOriginalGriff29-Dec-20 2:23 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268429-Dec-20 9:20
MemberMember 1357268429-Dec-20 9:20 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
OriginalGriff29-Dec-20 9:35
mveOriginalGriff29-Dec-20 9:35 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268429-Dec-20 9:45
MemberMember 1357268429-Dec-20 9:45 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
OriginalGriff29-Dec-20 10:05
mveOriginalGriff29-Dec-20 10:05 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Dave Kreskowiak29-Dec-20 16:15
mveDave Kreskowiak29-Dec-20 16:15 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268430-Dec-20 11:08
MemberMember 1357268430-Dec-20 11:08 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Dave Kreskowiak30-Dec-20 11:47
mveDave Kreskowiak30-Dec-20 11:47 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Member 1357268430-Dec-20 11:54
MemberMember 1357268430-Dec-20 11:54 
GeneralRe: String Replacement in 'HTML 5 FireFox' Pin
Dave Kreskowiak30-Dec-20 11:57
mveDave Kreskowiak30-Dec-20 11:57 
QuestionCase Conversion Regular Expression in JAVA 8 Pin
Member 1357268427-Dec-20 22:13
MemberMember 1357268427-Dec-20 22:13 
AnswerRe: Case Conversion Regular Expression in JAVA 8 Pin
Richard MacCutchan27-Dec-20 22:48
mveRichard MacCutchan27-Dec-20 22:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.