Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using regular expression how do i change characters(letters) into "#"

123456789please987654321help12345me123
123456789######987654321####12345##123 - result
Posted

Try:
C#
Regex regex = new Regex("[a-zA-Z]");
string result = regex.Replace(InputText,"#");


Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 
Comments
[no name] 3-Feb-12 3:32am    
im just using a Microsoft word. The find and replace.
without using the "replace with:" field
what regular expression should i use?
i need to modify the [a-zA-Z] in order to get the right output.
Thanks a lot.
OriginalGriff 3-Feb-12 3:57am    
If you are using Word, and want a Word specific reply, then you have to tell us that!

Read this: http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx#_Toc286834986
It may help.
[no name] 3-Feb-12 4:59am    
iv been here but this site is using "replace with" field. but thanks for the effort. . .i appreciated it. ^^
OriginalGriff 3-Feb-12 5:04am    
Yes. "Replace with" "#" I suspect...
[no name] 3-Feb-12 5:21am    
anyway what if i want to replace the two ## into #
the output will look like this
123456789######987654321####12345#123
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900