import tensorflow as tf

#https://stackoverflow.com/questions/47460722/how-to-perform-regex-operations-on-a-string-tensor-on-tensorflow

def remove_urls(vTEXT):
    vTEXT = re.sub(r'(https|http)?:\/\/(\w|\.|\/|\?|\=|\&|\%)*\b', 'url', vTEXT, flags=re.MULTILINE)
    return(vTEXT)


input_string_ph = tf.constant("This is string https:www.someurl.com")

input_string_lower = tf.py_func(lambda x: x.lower(), [input_string_ph], tf.string, stateful=False)
# input_string_no_url = tf.py_func(lambda x: remove_urls(x), [input_string_lower], tf.string, stateful=False)
sess = tf.InteractiveSession()
print (input_string_lower.eval())
