skip to Main Content

In my React Native app i’m fetching json data which contains raw html tags.How to remove the html tags from that?Following is the json response i’m getting

[{
    "data": {
        "course": {
            "id": 2864,
            "name": "2. Understanding India’s economic transition",
            "date_created": 1506154480,
            "status": "publish",
            "price": false,
            "price_html": "FREE",
            "total_students": 0,
            "seats": "",
            "start_date": false,
            "average_rating": 0,
            "rating_count": 0,
            "featured_image": "https://www.mywebsite.com/lms/wp-content/themes/wplms/assets/images/avatar.jpg",
            "categories": [],
            "instructor": {
                "id": "22",
                "name": "aami",
                "avatar": "https://www.mywebsite.com/lms/wp-content/uploads/2017/11/favicon.png",
                "sub": ""
            },
            "menu_order": 0
        },
        "description": "<p style="text-align: justify;">India is undergoing an economic, social and technological transformation. Perhaps no other phase is going to be as critical as the present one in shaping the future of the country as well as determining the welfare of the people. The economic transition is the vital ingredient of these overall change. Faster growth accompanied by industrial sector expansion, skill addition to the people, creation of quality infrastructure etc. will fuel this growth phase.</p>n<p style="text-align: justify;">For understanding how important is the present development phase, we have to adopt a historical and comparative study. Following factors helps us to understand the present development phase of India.</p>nn<ol style="text-align: justify;">n t<li><strong>Achievement of higher growth rate as a middle-income economy. </strong></li>n</ol>n<p style="text-align: justify;">India at present is a lower middle-income economy and has to become a high-income economy undergoing a rapid growth phase extending at least three decades.</p>n<p style="text-align: justify;">Most important narrative about the Indian economy is that it is the third largest in the world in terms of Purchasing Power Parity GDP. But a superior way to asses a country’s development is to consider per capita income. The widely used ranking about countries’ economic position is that of the World Bank’s GDP Per capita (constant US $) and the data for 2016 shows that India’s per capita income is $1861 compared to China’s $ 6994.</p>n<p style="text-align: justify;">Table: Categorization of countries by World Bank</p>nn<table>n<tbody>n<tr>n<td width="198"><strong>Category</strong></td>n<td width="318"><strong>PCI as on 2015 in constant US Dollar</strong></td>n</tr>n<tr>n<td width="198">Low Income Economy</td>n<td width="318">$ 1025 or less</td>n</tr>n<tr>n<td width="198">Middle Income Economynn(India - $ 1861)</td>n<td width="318">$1026 to $4035 (Lower Middle Income)nn$4036 to $12475 (Upper Middle Income)</td>n</tr>n<tr>n<td width="198">Higher Income Economy</td>n<td width="318">$ 12476 and above</td>n</tr>n</tbody>n</table>n<p style="text-align: justify;">According to World Bank metrics, a country with less than $1045 is considered as low-income economy whereas one with a PCI of $12736 or higher is considered as a higher income economy. Higher income means higher standard of living. India is at the bottom of the lower middle-income economies and has to achieve higher economic growth, structural changes including industrialisation to raise per capita income near to the $12736 mark in the long run. This is what the country has to achieve through the transition.</p>nn<ol style="text-align: justify;" start="2">n t<li><strong> Industrial sector expansion</strong></li>n</ol>n<p style="text-align: justify;">There are several factors that drives the economy to prosperity. Per capita income is just a monitored goal. How it can be raised is through achieving more productivity and employment generation in the sectors that can create big changes is decisive element for the country’s transition. Here comes the role of industrial sector. The industrial sector is known for generating huge employment with minimum skill addition. Similarly, no other sector has higher level of tradability as the industrial sector (means a country can earn big income through exports). Graduating to an expanded services sector without undergoing industrialisation will be self-defeating and unsuitable to a big economy like India. Depending on services sector for exports will not reward as other countries like to protect their services sector from the inflow of India’s skilled persons. If India can increase the contribution of the industrial sector in GDP from the present 30 per cent to say 40-45%, it implies that sizable income and employment are created in the sector.</p>nn<ol style="text-align: justify;" start="3">n t<li><strong> Skilling the people when demography favours.</strong></li>n</ol>n<p style="text-align: justify;">India has the largest number of young people in the world besides having largest workforce age group population. This situation is expected to remain till 2045. Now, youth means higher ability to produce, consume and thus stimulate overall economic activities. As in the case of an individual, better things happen for an economy when it is young.</p>nn<ol style="text-align: justify;" start="4">n t<li><strong> Infrastructure generation.</strong></li>n</ol>n<p style="text-align: justify;">Infrastructure is the platform for fueling growth. The government has launched several programmes to build quality infrastructure to assist economic transformation. In the industrial sector, there is the industrial corridor project; in transportation – there is the NHDP, PMGSY, Bhartamala, Sagarmala etc. Similarly, digital infrastructure is undergoing a qualitative improvement along with the education sector.</p>nn<ol style="text-align: justify;" start="5">n t<li><strong> Building invention and Innovation.</strong></li>n</ol>n<p style="text-align: justify;">Development is dynamic and present day developing economies can’t achieve development with the strategy of the past. Fourth industrialisation, robotics, artificial intelligence etc., proved that industrialisation is not labour oriented. Here, Countries like China with the aid of superior technology with its sizable labour force can produce and supply goods to the entire world. Competing in the new age industrial sector need good technological adaptation and a progressive national invention and educational systems.</p>nn<ol style="text-align: justify;" start="6">n t<li><strong> Easing of Doing Business.</strong></li>n</ol>n<p style="text-align: justify;">India’s business environment is historically suffocated by excess regulations and slow bureaucratic functions that are unsuitable for enterprise development.. But in recent years, institutional reforms are taking place and development blocking regulations are in the process of elimination.</p>n<p style="text-align: justify;">Development has become a major theme of the government and every issue related with economic prosperity are sophisticatedly addressed. Improvements in all the above field is slowly yielding results. Despite the adverse global slowdown and anti-globalisation headwinds, India continues to be the fastest growing large economy.</p>",
        "curriculum": false,
        "reviews": [],
        "instructors": [{
            "id": "22",
            "name": "tojo",
            "avatar": "https://www.mywebsite.com/lms/wp-content/uploads/2017/11/favicon.png",
            "sub": "",
            "average_rating": 0,
            "student_count": 0,
            "course_count": "0",
            "bio": false
        }],
        "purchase_link": false
    },
    "headers": [],
    "status": 200
}]

I’m listing description inside a card. So how to remove html tags?Please do help..Is there a way to do this?

2

Answers


  1. What about this?

    const regex = /(<([^>]+)>)/ig;
    const result = data.description.replace(regex, '');
    
    Login or Signup to reply.
  2. I also faced this challenge in my app.
    After trying several library, i’d like to recommand you react-native-render-html

    It allows you to provide ‘html’ to a Native component and have a simple text as an output.
    You can also customize each tag to give them specific style or ignore some of them.

    It does not require you to use ‘react link’ to make it work so you can use it in your expo app as well.

    Hope it helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search