How to remove the extra characters of a string in asp.

Asp+SQL database
A row of data, it is a # plus the last digit, but some data more than a # how to remove excess#
For example
Liu boss#1#1
Boss Wang#2#2
Zhang boss#3
Boss Lee#4#4
...
Zhu boss#288

Please teach me, thank you!

Started by Albert at February 07, 2016 - 4:34 PM

How to remove excess # and digital

Posted by Albert at February 11, 2016 - 4:54 PM

Write a replacement function on the line

Posted by Mandel at February 19, 2016 - 5:13 PM

The use of regular

str="Liu boss#1#1"
Set RegEx = New RegExp 
RegEx.Pattern = "(\#\d+?)(.*?)\1" 
RegEx.IgnoreCase = True 
RegEx.Global = True 
str = RegEx.Replace(str,"$1$2") 
Set RegEx = Nothing


Try this.

Posted by Julie at November 11, 2016 - 11:01 AM

The ASP page is running error!

Microsoft VBScript runtime error (0x800A000D)
Type mismatch: 'RegEx.Replace'
/UPAhoneAssist/upname.asp, The twenty-ninth line


Code
!--#include file="conn2.asp"-->
<!--#include file="conn.asp"-->

<%
Server.ScriptTimeOut=600

'------
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from contact ",conn,1,3
i=1

do while not rs.eof

name1=rs("name")
str=name1
Set RegEx = New RegExp
RegEx.Pattern = "(\#\d+?)(.*?)\1"
RegEx.IgnoreCase = True
RegEx.Global = True
str = RegEx.Replace(str,"$1$2")
Set RegEx = Nothing

response.write str

rs.movenext
response.write i
response.write "<BR>"
loop
rs.Close
set rs=nothing

response.write " Complete"
%>


This line of code.?
Twenty-ninth STR = RegEx.Replace(str,"$1$2")

Posted by Albert at November 26, 2016 - 11:25 AM

Set regEx = New RegExp
regEx.Pattern = "(#\d+)+"
regEx.Global = True
str = regEx.Replace(str, "$1")
Set RegEx = Nothing

Posted by Elvis at November 28, 2016 - 11:43 AM

Error type:
Microsoft VBScript runtime error (0x800A000D)
Type mismatch: 'regEx.Replace'
/UPAhoneAssist/upname.asp, The twenty-eighth line


The 28 line
str = regEx.Replace(str, "$1")

Posted by Albert at December 10, 2016 - 12:04 PM

1, Statistical variable character frequency
2, If greater than or equal to 2, then processing
A circular, all rows at a time

Posted by Hunter at December 14, 2016 - 12:40 PM

I don't know what you're doing
str="Liu boss#1#1"
Set RegEx = New RegExp 
RegEx.Pattern = "(\#\d+?)(.*?)\1" 
RegEx.IgnoreCase = True 
RegEx.Global = True 
str = RegEx.Replace(str,"$1$2") 
Set RegEx = Nothing
response.Write str

During the test no problem
Cannot use should be for the reasons you that is a null value.

Posted by Julie at December 28, 2016 - 1:31 PM

I give you is no problem, the test can be used

Posted by Julie at January 08, 2017 - 3:34 PM

According to this test can indeed
str="Liu boss#1#1"
Set RegEx = New RegExp 
RegEx.Pattern = "(\#\d+?)(.*?)\1" 
RegEx.IgnoreCase = True 
RegEx.Global = True 
str = RegEx.Replace(str,"$1$2") 
Set RegEx = Nothing
response.Write str


But according to
str=rs("name")
Set RegEx = New RegExp 
RegEx.Pattern = "(\#\d+?)(.*?)\1" 
RegEx.IgnoreCase = True 
RegEx.Global = True 
str = RegEx.Replace(str,"$1$2") 
Set RegEx = Nothing
response.Write str

This prompts an error.
Don't know why.?

Posted by Albert at January 11, 2017 - 1:46 PM

Because some record is empty, so wrong. Thank you chinmo webmaster!

Posted by Albert at January 15, 2017 - 2:44 PM