hyphen_problem / app.py
SitwalaM
added extra fix
a43dbe9
raw
history blame contribute delete
675 Bytes
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.")