Spaces:
Sleeping
Sleeping
File size: 675 Bytes
f6b9e7f c649b24 f6b9e7f c649b24 b9069b0 a43dbe9 c649b24 f6b9e7f c649b24 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import streamlit as st
import re
def clean_text(text):
# Replace hyphen followed by space or multiple spaces with just a hyphen
text = re.sub(r'-(?=\w)', '', text)
text = re.sub(r'-\s+', '', text)
return text
# Title of the Streamlit app
st.title('Text Cleaner')
# Input text from the user
input_text = st.text_area("Enter text to clean:")
# Button to trigger cleaning
if st.button('Clean Text'):
if input_text:
# Clean the text
cleaned_text = clean_text(input_text)
# Display the cleaned text
st.subheader("Cleaned Text")
st.write(cleaned_text)
else:
st.warning("Please enter some text to clean.")
|