[Forum FAQ] How to remove div characters from multiline textbox field in SharePoint 2013

Scenario:
Need to avoid the div tags and get data alone from multiline textbox field using JavaScript Client Object Model in SharePoint 2013.
Solution:
We can use a regular expression to achieve it.
The steps in detail as follows:
1. Insert a Script Editor Web Part into the page.
2. This is the complete code, add it into the Script Editor Web Part and save.
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
function retrieveListItems() {
// Create an instance of the current context to return context information
var clientContext = new SP.ClientContext.get_current();
//Returns the list with the specified title from the collection
var oList = clientContext.get_web().get_lists().getByTitle('CustomListName');
//use CAML to query the top 10 items
var camlQuery = new SP.CamlQuery();
//Sets value that specifies the XML schema that defines the list view
camlQuery.set_viewXml('<View><RowLimit>10</RowLimit></View>');
//Returns a collection of items from the list based on the specified query
this.collListItem = oList.getItems(camlQuery);
clientContext.load(this.collListItem, 'Include(Title,MultipleText)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded() {
//Returns an enumerator to iterate through the collection
var listItemEnumerator = this.collListItem.getEnumerator();
//Remove div tag use a regular expression
var reg1 = new RegExp("<div class=\"ExternalClass[0-9A-F]+\">[^<]*", "");
var reg2 = new RegExp("</div>$", "");
//Advances the enumerator to the next element of the collection
while (listItemEnumerator.moveNext()) {
//Gets the current element in the collection
var oListItem = listItemEnumerator.get_current();
alert(oListItem.get_item('MultipleText').replace(reg1, "").replace(reg2, ""));
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
</script>
Result:<o:p></o:p>
References:
http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

Nice article :)
If this helped you resolve your issue, please mark it Answered

Similar Messages

  • How to remove the characters from first and last position of a string?

    Hi all,
    I am creating an application where i am using vb script to export the data to excel.
    In the excel sheet most of the values are entered with double " quotes.
    so the entry looks like ""http://www.sap.com"".
    Notice that it is starting with "" and not " . so the vb takes it as a line feed and shows an error .
    It will be great if anybody can tell me how to remove these set of quotes ,so that the value should come as "http://www.sap.com" . A sample code wil be of great help.
    Thanks in advance,
    mahima.

    Hi,
    To modify you excel you have 2 options, 1) you can filter them in excel itself by using filter ...etc in excel itself. or 2) you can do it by using ABAP code.
    Below code may help you.
    Get the data from Excel to Internal table using FM :
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                = 'c:\temp\test.xls'
        i_begin_col             = 1
        i_begin_row             = 1
        i_end_col               = w_values
        i_end_row               = 10
      tables
        intern                  = t_alsmex_tabline
      exceptions
        inconsistent_parameters = 1
        upload_ole              = 2
        others                  = 3.
    Now replace all unwanted "" in internal table with space.
    replace all occurrences of '""' in itab-field with '   '.
    Again you can export to Excel using
      call function 'GUI_DOWNLOAD'
        exporting
          filename                = lv_file
          filetype                = 'DAT'
          append                  = ' '
          write_field_separator   = 'X'
        tables
          data_tab                = itab.

  • How To Supress Few Characters From a ZTable field.

    Hi,
      I have a Field called 123-abc in my Ztable. That is driven by concatinating 2 fields from standard SAP Table.
    Now I want to Compare the Ztable-field with one of the field from Standard SAP field like 123.
    How to do that??

    Do something like this -;)
    REPORT ZDUMMY_ATG.
    DATA: T1 TYPE STRING,
          T2 TYPE STRING,
          POS TYPE I,
          LONG TYPE I.
    T1 = '123-ABC'.
    T2 = '123'.
    TRANSLATE T1 TO UPPER CASE.
    SEARCH T1 FOR '-'.
    POS = SY-FDPOS + 1.
    LONG = STRLEN( T1 ).
    LONG = LONG - POS.
    IF T1+0(LONG) EQ T2.
      WRITE 'The Same...'.
    ELSE.
      WRITE 'Not the Same...'.
    ENDIF.
    Greetings,
    Blag.

  • [Forum FAQ] How to display an image from Http response in Reporting Services?

    Question:
    There is a kind of scenario that users want to display an image which is from URL. In Reporting Services, if the URL points to an image file, we can directly display it by typing the URL in embedded image. However, some URLs are just sending Http requests
    to server side, then redirect to another position and the server will return the image. For these kind of URLs, Reporting Services can’t directly render the image from Http response.
    Answer:
    To achieve this goal, we can add custom code into the report. Pass the URL as argument into our custom function so that we can create HttpRequest and get the HttpResponse. Then we can use custom function to return the Bytes() from the HttpResponse and render
    it into an image in report.
    Ps: In Reporting Services, it only support drawing Bytes() array into image, so we need to have our custom function return Bytes array.
    Add the assembly and custom code into the report.
    Public shared Function GetImageFromByte(Byval URL as String) As byte() 
                    Dim photo as System.Drawing.Image 
             Dim Request As System.Net.HttpWebRequest 
           Dim Response As System.Net.HttpWebResponse 
                  Request = System.Net.WebRequest.Create(URL)         
                     Response = CType(Request.GetResponse, System.Net.WebResponse) 
                 If Request.HaveResponse Then  
                      If Response.StatusCode = Net.HttpStatusCode.OK Then                    
                           photo = System.Drawing.Image.FromStream(Response.GetResponseStream) 
                     End If 
                 End If 
                  Dim ms AS System.IO.MemoryStream = new System.IO.MemoryStream() 
                 photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) 
                    Dim imagedata as byte()  
                    imagedata = ms.GetBuffer()  
                    return imagedata
    End Function
    Grant the permission for assemblies. 
    Go to: 
    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\RSpreviewPolicy.config 
    C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\rssrvpolicy.config
    Give “FullTrust” for Report_Expressions_Default_Permissions.
    Insert an image into report. 
    Expression:
    =Code.GetImageFromByte("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSrVwPoAtlcA2A3KaiAJi-XjS4icr1QUnKYr7uzpX3IL3g2GPisAQ")
    The Result looks below:
    Applies to:
    Reporting Services 2005
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012
    Reporting Services 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    >
    Hi, I'd like to display a dynamic image from the web inside a JLabel or any other swing component it could work in. I've been looking on the Swing tutorials and others forums, all I can have is that a JLabel can load an Icon object, defined by an image URL, but can this URL be like "http://xxxxx/image.jpg" somehow or can it only be a local image URL?>
    I do not know why you start talking about an image on the web then go on to show concerns about whether it will work for a 'local' URL.
    But perhaps this answer will cover the possibilities.
    So long as you can from an URL to the image, and the bytes are available for download (e.g. some web sites wrap a direct call to an image in HTML that embeds the image), the URL based icon constructors will successfully load it.
    It does not matter if that URL points to
    - a web site,
    - a local server ('localhost'),
    - an URL representation of a File on the local file system, or
    - it is inside a Jar file that is on the application's run-time classpath.
    How you go about forming a valid URL to a 'local resources' (or indeed what you regard as local resources) is another matter, depending on the form of the project, and how the resources are stored (see list above).
    Probably the main reason that examples use images at a hard coded URL on the net is that it makes an 'image example' self contained. As soon as we compile and run it, we can see the result. I have posted a few examples like that on these forums.
    Edit 1:
    BTW - Welcome to the Sun forums
    Edited by: AndrewThompson64 on Apr 21, 2009 12:15 PM

  • How to removed leading zeros from a date field.

    CONVERT(NVARCHAR, CONVERT(DATETIME, CONVERT(CHAR(8), STM.CreationDate)), 101)
    This is what i currently have, but prints 02/03/2014 i would like to print the date without the zeros when applicable.
    Thanks in advance.

    >>REPLACE(LTRIM(REPLACE(CONVERT(NVARCHAR, CONVERT(DATETIME, CONVERT(CHAR(8), STM.CreationDate)), 101),'0', ' ')), ' ', '0')
    Does this query really works? I doubt
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • HT2500 Does anyone know how to remove a group from the address panel in mail?

    Does anyone know how to remove a group from the address panel in mail?

    I haven't seen too many questions like this on this forum.  Did you also try the photoshop forums?

  • How to remove corrupt image from iPhoto

    Somewhere in my photo library I have a photo that iPhoto really doesn't like! I want to know how to remove this image from my library, possibly by deleting it via Finder.
    When I scroll through my photos in iPhoto the software hangs momentarily, and then crashes completely, whenever it gets to this particular image. When I try to export my photos (for backup purposes) iPhoto always crashes when trying to export this same image.
    The problem has appeared with one of the recent updates to iPhoto, when I originally imported this image I could see and export the image just fine. The same issue is preventing me from migrating my photo library to the new Photos app - the import process that runs when I first launch Photos always crashes at the same point, presumably because of this same image file.
    I am unable to remove the image by deleting it via iPhoto because I can't get iPhoto to display the image without crashing, please can anyone suggest another way to get rid of it.

    I've been trying to post details from the crash report here, but the forum software tells me that the message contains 'an invalid character' - which character is invalid? Who knows...

  • How to remove memory modules from Toshiba notebooks?

    You can remove the memory module from your laptop,this is the hardware related technique.

    Here you can find a nice Forum place containing some workarounds how to remove and replace the modules.
    [How to remove memory modules from Toshiba notebooks?|http://forums.computers.toshiba-europe.com/forums/forum.jspa?forumID=114]

  • How to remove special characters while typing data in edit cell in datagrid in flex4

    Hi Friends,
    I am facing this problem "how to remove special characters while typing data in edit cell in datagrid in flex4".If know anyone please help in this
    Thanks,
    Anderson.

    Removes any characters from
    @myString that do not meet the
    provided criteria.
    CREATE FUNCTION dbo.GetCharacters(@myString varchar(500), @validChars varchar(100))
    RETURNS varchar(500) AS
    BEGIN
    While @myString like '%[^' + @validChars + ']%'
    Select @myString = replace(@myString,substring(@myString,patindex('%[^' + @validChars + ']%',@myString),1),'')
    Return @myString
    END
    Go
    Declare @testStr varchar(1000),
    @i int
    Set @i = 1
    while @i < 255
    Select
    @TestStr = isnull(@TestStr,'') + isnull(char(@i),''),
    @i = @i + 1
    Select @TestStr
    Select dbo.GetCharacters(@TestStr,'a-z')
    Select dbo.GetCharacters(@TestStr,'0-9')
    Select dbo.GetCharacters(@TestStr,'0-9a-z')
    Select dbo.GetCharacters(@TestStr,'02468bferlki')
    perfect soluction

  • How to remove credit card from iphone4s

    how to remove credit card from iphone4s

    Not sure what you mean by this. Are you trying to remove your credit card information from the App Store/iTunes store?

  • How to remove available downloads from the list

    how to remove available downloads from the list without it resuming when i open itunes or check for available downloads?

    There is not a way to remove them from the list.  Just let them download, and then delete them from your library when they are done.

  • How to remove "open dns" from imac

    how to remove "open dns" from imac

    Unlock the Network preference pane, if necessary, by clicking the lock icon in the lower left corner and entering your password. Cllck Advanced, open the DNS tab, and delete the server addresses. Click OK and then Apply.

  • How to remove SD Card from the Card Reader slot - Satellite A100?

    Hi,
    Is there anyone to help me? I inserted a 64 MB SD card in the card reader slot of my Toshiba A100 model. It's the first time i have inserted the card. The card is inside the slot. I can not take it out! I don't have any idea how to remove the card from the card reader slot. I can see the contents of my SD card, can open the files too. But how to remove it out from the slot. Please help me giving your idea to remove the card out from the slot.
    Arjun

    Hi
    In my knowledge the SD card slot doesnt has a any additional helps like the PCMCIA slot to remove the card.
    You have to remove it simply. Try to grab the card and move it out. You can try to use the pair of tweezers. Maybe it helps

  • How to remove sd card from iMac

    hi how to remove sd card from imac ,thanks

    If your machine is in warranty, be careful not to do anything more that might damage it when removing it from the optical drive.  You might even be able to convince an authorized service technician to carefully remove it under warranty from the optical drive.  It is a design issue that lets people accidentally insert the SD card in the optical drive.   Of course if that's the only copy of your information on the SD card, be sure to let them know that, so they are extra careful not to damage it when removing it.

  • How to remove an ipad from my account

    I am given my first ipad away, how i remove this ipad from my account? I already reset all contents.

    See http://support.apple.com/kb/HT5661.

Maybe you are looking for

  • N96 No Message Sounds after update to 12.043

    I've recently updated my phones firmware to 12.043, impressed how much more resposive the phone is. However I now have an issue when I get a new text message the phone does not make any sound. I have checked the profile is on general and that the mes

  • Is this real or is this dangerous mail in apple's name ?

    I recieved this mail yesterday but I'm not sure what it means? I don't want to open the attachment because of the bad english used in the mail. Althought it was send from [email protected] I'm in serious doubt that this is a genuine mail from apple?

  • XML parsing in flash

    Hi, I'm using the following technique inorder to parse the XML like this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;.... Just want to known if there is any way in Macromedia flash where in we can you element by names for parsing XML

  • 404 Error when loading IWeb page

    Greetings once again! I have been using the IWeb program for setting up my business in nature photograhy and have passed out business cards that say web.mac.com/debo0063/iweb and people have been telling me they get 404 errors when they look up my si

  • HOW TO REGISTER jars ???

    Hi guys, I've got a problem during (un)deployment of sda files. If I try to undeploy my adapter.sda I get : [permissions_collection_operator]: domain[apps//ecs.com/com.ecs.aii.af.tc.ra/connector/connectors/adapter.rar/adapter.jar] not removed, becaus