0

All I want to do is moving a formatted values from asp literal to a string.

Eg:

<asp:literal id='test'> </asp:literal>

In .cs

test.Text = '<b tag>USA</b tag>';
String newTest = test.Text;

As of am getting 'USA' this value in the string newTest. All I am trying to get is USA.

  • I am not sure what you're trying to do; the 1st line of your `cs` file will set the text of the literal to 'USA' which doesn't look like valid html syntax (you don't need the `tag`, just ``). But then are you trying to get the same html value back into the `newTest` variable? Why would you do that from the Literal and not just code behind where you have access to that string anyway? – Simon Martin Apr 26 '13 at 15:46
  • Exactly am using only... here in Stackoverflow to mention it I put that way. Else Stackoverflow is formatting on its own. – Vimalathithan Rajasekaran Apr 26 '13 at 15:50

1 Answers1

0

Using a regular expression:

const string input = "<b tag>USA</b tag>";
var match = Regex.Match(input, @"\>(?<country>.*)\<\/");
var country = match.Groups["country"].Value;

This will match anything inbetween > and </

ChrisO
  • 5,068
  • 1
  • 34
  • 47