Question:
Regex: how do I replace just a part of the pattern I'm matching?
rissaofthesaiyajin
2007-03-02 11:38:10 UTC
What I'm thinking of is something like matching a lower-case character followed by a full stop, then just replacing the full stop with a comma. So something like

[a-z]\.

to

[a-z],

But I can't figure out how to get the regex to 'ignore' the lower-case character. I'm working in VB 6, if that matters.

Anyone?
Five answers:
injanier
2007-03-02 14:40:12 UTC
In Perl, you would write

$line =~ s/([a-z])\./$1,/g;

$1 refers to whatever was matched in the parentheses. I'm not familiar with with what's available in VB6.



Oops, forgot about lookbehind:

(?<=[a-z])\. matches a "." preceded by a lower case letter, without making the letter part of the match. Again, works in Perl, not sure about VB.
anonymous
2007-03-02 13:03:56 UTC
Er...



Why would you be wishing to ignore the lower case

character, when that is exactly what you are trying

to match??



What you have written,



[a-z]\.



will match *any* lower case character which is

followed by a full stop.



All you need do is specify the format for the replacement text, as in,



[a-z]\,



Since I've never used Visual Basic, I can't tell you

what the command syntax would be for replacement

rather than match. Over to you there.



You can have the expression in Perl if you like? But,

its a pretty straightforward swap, really. ;o)



Anyway, HTH.
yockey
2016-10-02 10:47:32 UTC
India had a distinctive to suitable journey after Australia's first innings batting,i presumed it replaced into solid first innings from Aussies yet India scored so quickly attributable to Dhawan and co and Australia's 2d innings capitulation that befell so without postpone on the final day won't be able to be defined even with the help of Ian Chappell.Batting for India clicked so properly in this sequence,that they had a distinctive to suitable journey.Australia could desire to've drawn this journey yet they ended up dropping on the final day attributable to a pair poor batting in 2d innings.
NoComment
2007-03-09 15:30:03 UTC
if you have a string in VB6 use the LCase function

Ex



dim s1 as string

s1="AbCdE"

dim s2 as string

s2="ABCDE"

if LCase(s1)=LCase(s2) then

msgbox (s1 & " = " & s2)

else

msgbox "You Fail at Life."

end if
Lord Jimothy
2007-03-08 03:02:39 UTC
vI have been searching for a long time to try to find a calendar application like the one on a now-abandoned site that a local ministry group had put up a couple of years ago. The calendar consisted of hour-long blocks of time around the clock and people would sign up to commit to pray for local churches during the period for which they were signed up, and they would receive notification e-mails as reminders before the time for which they signed up. I've tried to reach the programmer who put the site together, but he doesn't live in this area, and the people who worked with him to set up the site aren't sure where the application came from. If any of you could tell me where I might find an application like the one at this link, I would be very grateful:





http://24-7terrehaute.com/signup.asp...



I have been searching for a long time to try to find a calendar application like the one on a now-abandoned site that a local ministry group had put up a couple of years ago. The calendar consisted of hour-long blocks of time around the clock and people would sign up to commit to pray for local churches during the period for which they were signed up, and they would receive notification e-mails as reminders before the time for which they signed up. I've tried to reach the programmer who put the site together, but he doesn't live in this area, and the people who worked with him to set up the site aren't sure where the application came from. If any of you could tell me where I might find an application like the one at this link, I would be very grateful:





http://24-7terrehaute.com/signup.asp...



I have been searching for a long time to try to find a calendar application like the one on a now-abandoned site that a local ministry group had put up a couple of years ago. The calendar consisted of hour-long blocks of time around the clock and people would sign up to commit to pray for local churches during the period for which they were signed up, and they would receive notification e-mails as reminders before the time for which they signed up. I've tried to reach the programmer who put the site together, but he doesn't live in this area, and the people who worked with him to set up the site aren't sure where the application came from. If any of you could tell me where I might find an application like the one at this link, I would be very grateful:





http://24-7terrehaute.com/signup.asp...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...